Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 19:41
Show Gist options
  • Save anonymous/4487217 to your computer and use it in GitHub Desktop.
Save anonymous/4487217 to your computer and use it in GitHub Desktop.
An example of a timeout test for rx
[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