ReactiveUI - Testing

Testing

Testing

ReactiveUI includes a few tools to help testing, building on what Rx already includes (see introtorx) for details.

The utilities are included in the ReactiveUI.Testing nuget package.

Custom Scheduler

A common pattern is to replace the schedulers ReactiveUI is using to test execution is occuring without injecting schedulers everywhere. This can be achieved in a couple of ways

using(TestUtils.WithScheduler(ImmediateScheduler.Instance))
{
  // your test here
}

Or

(new TestScheduler()).With(sched => {
  ... // Do something
  sched.AdvanceByMs(2 * 100); // Play with time
  ...
});

More details are on the docs site.