Created
January 8, 2013 19:41
-
-
Save anonymous/4487217 to your computer and use it in GitHub Desktop.
An example of a timeout test for rx
This file contains 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
[Fact] | |
public void timeout() | |
{ | |
var observable = Observable.Never<decimal>(); | |
int timesRun = 0; | |
int timeouts = 0; | |
observable.Subscribe(x => timesRun++); | |
var testScheduler = new TestScheduler(); | |
observable.Timeout(TimeSpan.FromSeconds(1), testScheduler).Subscribe(x => timesRun++, | |
e => | |
{ | |
timeouts++; | |
}); | |
Assert.Equal(0, timesRun); | |
testScheduler.AdvanceBy(TimeSpan.FromSeconds(1).Ticks - 1); | |
Assert.Equal(0, timeouts); | |
testScheduler.AdvanceBy(1); | |
//testScheduler.Start(); | |
Assert.Equal(1, timeouts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment