public static IEnumerable <Recorded <Notification <T> > > Run <T>(this TestScheduler scheduler, Func <IObservable <T> > create, ushort created, ushort subscribed, ushort disposed) { var source = default(IObservable <T>); var subscription = default(IDisposable); var observer = new MockObserver <T>(scheduler); scheduler.Schedule(() => source = create(), created); scheduler.Schedule(() => subscription = source.Subscribe(observer), subscribed); scheduler.Schedule(() => subscription.Dispose(), disposed); scheduler.Run(); return(observer); }
public void Bug_1381() { var scheduler = new TestScheduler(); var xs = scheduler.CreateHotObservable( OnNext(90, 1), OnNext(110, 2), OnNext(250, 3), OnNext(270, 4), OnNext(280, 5), OnNext(301, 6), OnNext(302, 7), OnNext(400, 8), OnNext(401, 9), OnNext(510, 10) ); var results = new MockObserver <int>(scheduler); var ys = default(IConnectableObservable <int>); var connection = default(IDisposable); var subscription = default(IDisposable); scheduler.Schedule(() => ys = xs.Replay(scheduler), 100); scheduler.Schedule(() => connection = ys.Connect(), 200); scheduler.Schedule(() => subscription = ys.Subscribe(results), 300); scheduler.Schedule(() => subscription.Dispose(), 500); scheduler.Schedule(() => connection.Dispose(), 600); scheduler.Run(); results.AssertEqual( OnNext(301, 3), OnNext(302, 4), OnNext(303, 5), OnNext(304, 6), OnNext(305, 7), OnNext(400, 8), OnNext(401, 9) ); xs.Subscriptions.AssertEqual( Subscribe(200, 600) ); }
public void Bug_1381() { var scheduler = new TestScheduler(); var xs = scheduler.CreateHotObservable( OnNext( 90, 1), OnNext(110, 2), OnNext(250, 3), OnNext(270, 4), OnNext(280, 5), OnNext(301, 6), OnNext(302, 7), OnNext(400, 8), OnNext(401, 9), OnNext(510, 10) ); var results = new MockObserver<int>(scheduler); var ys = default(IConnectableObservable<int>); var connection = default(IDisposable); var subscription = default(IDisposable); scheduler.Schedule(() => ys = xs.Replay(scheduler), 100); scheduler.Schedule(() => connection = ys.Connect(), 200); scheduler.Schedule(() => subscription = ys.Subscribe(results), 300); scheduler.Schedule(() => subscription.Dispose(), 500); scheduler.Schedule(() => connection.Dispose(), 600); scheduler.Run(); results.AssertEqual( OnNext(301, 3), OnNext(302, 4), OnNext(303, 5), OnNext(304, 6), OnNext(305, 7), OnNext(400, 8), OnNext(401, 9) ); xs.Subscriptions.AssertEqual( Subscribe(200, 600) ); }