forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputTest.cs
More file actions
60 lines (50 loc) · 1.88 KB
/
InputTest.cs
File metadata and controls
60 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace ReactiveUI.Tests
{
public class InputScopeTests
{
[Fact]
public void InputScopeShouldInvokeCommandsInReverseOrder()
{
var view = new FakeView() { ViewModel = new FakeViewModel(), };
var fixture = new KeyboardManager();
fixture.RegisterScope(
new InputSection("Foo",
view.GetInputCommand(x => x.ViewModel.Cmd, "Ctrl-C")));
fixture.RegisterScope(
new InputSection("Bar",
view.GetInputCommand(x => x.ViewModel.Cmd2, "Ctrl-C")));
var output = Observable.Merge(
view.ViewModel.Cmd.Select(_ => "Foo"),
view.ViewModel.Cmd2.Select(_ => "Bar"))
.CreateCollection();
fixture.InvokeShortcut("Ctrl-C");
Assert.Equal(1, output.Count);
Assert.Equal("Bar", output[0]);
}
[Fact]
public void InputScopeShouldntBlowUpOnMissingShortcut()
{
var view = new FakeView() { ViewModel = new FakeViewModel(), };
var fixture = new KeyboardManager();
fixture.RegisterScope(
new InputSection("Foo",
view.GetInputCommand(x => x.ViewModel.Cmd, "Ctrl-C")));
fixture.RegisterScope(
new InputSection("Bar",
view.GetInputCommand(x => x.ViewModel.Cmd2, "Ctrl-C")));
var output = Observable.Merge(
view.ViewModel.Cmd.Select(_ => "Foo"),
view.ViewModel.Cmd2.Select(_ => "Bar"))
.CreateCollection();
fixture.InvokeShortcut("Ctrl-R");
Assert.Equal(0, output.Count);
}
}
}