var scheduler = new TestScheduler(); var values = new Dictionary() { { 0, 1 }, { 100, 2 }, { 200, 3 } }; var observable = scheduler.CreateColdObservable(values); var observer = scheduler.CreateObserver (); observable.Subscribe(observer); scheduler.Start(); foreach (var item in observer.Messages) { Console.WriteLine(item.Value); }
OnNext(100, 2) OnNext(200, 3) OnCompleted()
var scheduler = new TestScheduler(); var values = new Dictionary() { { 0, 1 }, { 100, 2 }, { 200, 3 } }; var observer = scheduler.CreateObserver (); scheduler.ScheduleAbsolute(50, () => { observer.OnNext(0); }); scheduler.ScheduleAbsolute(150, () => { observer.OnNext(1); }); scheduler.ScheduleAbsolute(250, () => { observer.OnNext(2); }); scheduler.ScheduleAbsolute(300, () => { observer.OnCompleted(); }); scheduler.Start(); foreach (var item in observer.Messages) { Console.WriteLine(item.Value); }
OnNext(0, 1) OnNext(1, 2) OnNext(2, 3) OnCompleted()In conclusion, TestScheduler AdvanceMinimal is a package library in C# that provides an advanced minimal implementation of the TestScheduler class for testing time-based scenarios. It is a useful tool for testing reactive and asynchronous code.