Created
February 17, 2012 09:19
-
-
Save shiftkey/1852096 to your computer and use it in GitHub Desktop.
Testing IObservable processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleTest | |
{ | |
private readonly List<KeyPress> outputs; | |
private readonly KeyProvider provider; | |
private readonly Subject<InterceptKeyEventArgs> subject; | |
private IProcessLookup processLookup; | |
public ExampleTest() | |
{ | |
outputs = new List<KeyPress>(); | |
subject = new Subject<InterceptKeyEventArgs>(); | |
processLookup = Substitute.For<IProcessLookup>(); | |
provider = new KeyProvider(subject, processLookup); | |
provider.Subscribe(outputs.Add); | |
} | |
[Fact] | |
public void this_is_how_to_write_a_carnac_test() | |
{ | |
var keys = new List<InterceptKeyEventArgs> | |
{ | |
new InterceptKeyEventArgs(Keys.LControlKey, KeyDirection.Down, false, false, false), | |
new InterceptKeyEventArgs(Keys.LShiftKey, KeyDirection.Down, false, true, false), | |
new InterceptKeyEventArgs(Keys.L, KeyDirection.Down, false, true, true), | |
new InterceptKeyEventArgs(Keys.L, KeyDirection.Up, false, true, true), | |
new InterceptKeyEventArgs(Keys.LShiftKey, KeyDirection.Up, false, true, true), | |
new InterceptKeyEventArgs(Keys.LControlKey, KeyDirection.Up, false, true, false) | |
}; | |
foreach (var key in keys) | |
{ | |
subject.OnNext(key); | |
} | |
Assert.True(outputs.Count == 6); // we're not actually testing anything here, right? ShellViewModel is the bits you want to test. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment