public void FirstAsync_SourceErrorBeforeCheckpoint_FailAndReload() { var store = new InMemoryStateStore("someId"); var engine = CreateQueryEngine(); var reactive = engine.GetReactiveService(); var ex = new Exception(); var source = GetTestableQbservable(reactive, "source", OnError <int>(490, ex) // 500 // crash at 600 ); Assert.IsNotNull(source); var result = GetTestableQbserver <int>(reactive, "result"); Scheduler.ScheduleAbsolute(10, () => source.FirstAsync().Subscribe(result, new Uri("s:/sub1"), null)); Scheduler.ScheduleAbsolute(510, () => Checkpoint(engine, store)); Scheduler.ScheduleAbsolute(600, () => RemoveQueryEngine(engine)); Scheduler.ScheduleAbsolute(800, () => Recover(CreateQueryEngine(), store)); Scheduler.Start(); var sub = GetTestableSubscribable <int>("source"); sub.Subscriptions.AssertEqual( ReactiveTest.Subscribe(10, 10 + 490), ReactiveTest.Subscribe(800, 800)); var res = GetTestableObserver <int>("result"); res.Messages.AssertEqual( OnError <int>(500, ex)); }
public void TestMethod() { var scheduler = new TestScheduler(); var input = scheduler.CreateHotObservable( ReactiveTest.OnNext(100, "abc"), ReactiveTest.OnNext(200, "def"), ReactiveTest.OnNext(300, "ghi"), ReactiveTest.OnNext(400, "pqr"), ReactiveTest.OnNext(500, "test"), ReactiveTest.OnNext(600, "xyz"), ReactiveTest.OnCompleted <string>(800) ); var results = scheduler.Start( () => input.Buffer(() => input.Throttle(TimeSpan.FromTicks(100), scheduler)) .Select(b => string.Join(",", b)), created: 0, subscribed: 100, disposed: 800); ReactiveAssert.AreElementsEqual(results.Messages, new Recorded <Notification <string> >[] { ReactiveTest.OnNext(700, "def,ghi,pqr,test,xyz"), ReactiveTest.OnNext(800, ""), ReactiveTest.OnCompleted <string>(800) }); ReactiveAssert.AreElementsEqual(input.Subscriptions, new Subscription[] { ReactiveTest.Subscribe(100, 800), ReactiveTest.Subscribe(100, 700), ReactiveTest.Subscribe(700, 800) }); }
public void FirstAsync_TriggerAfterCheckpoint_FailAndReload() { var store = new InMemoryStateStore("someId"); var engine = CreateQueryEngine(); var reactive = engine.GetReactiveService(); var source = GetTestableQbservable(reactive, "source", // crash at 600 OnNext(900, 1) // 800 + 900 ); Assert.IsNotNull(source); var result = GetTestableQbserver <int>(reactive, "result"); Scheduler.ScheduleAbsolute(10, () => source.FirstAsync().Subscribe(result, new Uri("s:/sub1"), null)); Scheduler.ScheduleAbsolute(510, () => Checkpoint(engine, store)); Scheduler.ScheduleAbsolute(600, () => RemoveQueryEngine(engine)); Scheduler.ScheduleAbsolute(800, () => Recover(CreateQueryEngine(), store)); Scheduler.Start(); var sub = GetTestableSubscribable <int>("source"); sub.Subscriptions.AssertEqual( ReactiveTest.Subscribe(10), ReactiveTest.Subscribe(800, 800 + 900)); var res = GetTestableObserver <int>("result"); res.Messages.AssertEqual( OnNext(800 + 900, 1), OnCompleted <int>(800 + 900)); }
public void TakeUntil_RepeatedValues_FailAndReload() { var store = new InMemoryStateStore("someId"); var engine = CreateQueryEngine(); var reactive = engine.GetReactiveService(); var source = GetTestableQbservable(reactive, "source", OnNext(100, 1), // 110 OnNext(200, 2), // 210 OnNext(300, 3), // 310 OnNext(400, 4), // 410 OnNext(490, 5), // 500 OnNext(550, 6), // 550, 800 + 550 // crash at 600 OnNext(900, 9) // 800 + 900 ); Assert.IsNotNull(source); var triggeringSource = GetTestableQbservable(reactive, "triggeringSource", OnNext(560, 1) // 570, 800 + 560 ); Assert.IsNotNull(triggeringSource); var result = GetTestableQbserver <int>(reactive, "result"); Scheduler.ScheduleAbsolute(10, () => source.TakeUntil(triggeringSource).Subscribe(result, new Uri("s:/sub1"), null)); Scheduler.ScheduleAbsolute(510, () => Checkpoint(engine, store)); Scheduler.ScheduleAbsolute(600, () => RemoveQueryEngine(engine)); Scheduler.ScheduleAbsolute(800, () => Recover(CreateQueryEngine(), store)); Scheduler.Start(); var sub = GetTestableSubscribable <int>("source"); sub.Subscriptions.AssertEqual( ReactiveTest.Subscribe(10, 10 + 560), ReactiveTest.Subscribe(800, 800 + 560)); var subTrigger = GetTestableSubscribable <int>("triggeringSource"); subTrigger.Subscriptions.AssertEqual( ReactiveTest.Subscribe(10, 10 + 560), ReactiveTest.Subscribe(800, 800 + 560)); var res = GetTestableObserver <int>("result"); res.Messages.AssertEqual( OnNext(110, 1), OnNext(210, 2), OnNext(310, 3), OnNext(410, 4), OnNext(500, 5), OnNext(560, 6), OnCompleted <int>(570), OnNext(800 + 550, 6), OnCompleted <int>(800 + 560)); }
private void Then_n_projects_should_be_found() { var notifications = _sln.Projects.Select(p => ReactiveTest.OnNext(150, p)).ToList(); notifications.Add(ReactiveTest.OnCompleted <Project>(350)); ReactiveAssert.AreElementsEqual(notifications, _results.Messages); ReactiveAssert.AreElementsEqual(new Subscription[] { ReactiveTest.Subscribe(50, 350) }, _inputObservable.Subscriptions); }
public void TakeWhile_TriggerErrorAfterCheckpoint_FailAndReload() { var store = new InMemoryStateStore("someId"); var engine = CreateQueryEngine(); var reactive = engine.GetReactiveService(); var source = GetTestableQbservable(reactive, "source", OnNext(100, 1), // 110 OnNext(200, 2), // 210 OnNext(300, 3), // 310 OnNext(400, 4), // 410 OnNext(490, 5), // 500 OnNext(540, 6), // 550, 800 + 540 // crash at 600 OnNext(900, 9) // 800 + 900 ); Assert.IsNotNull(source); var result = GetTestableQbserver <int>(reactive, "result"); #pragma warning disable IDE0075 // Simplify conditional expression (used in expression tree) Scheduler.ScheduleAbsolute(10, () => source.TakeWhile(x => (x > 5) ? (x / (x - x)) == 0 : true).Subscribe(result, new Uri("s:/sub1"), null)); #pragma warning restore IDE0075 // Simplify conditional expression Scheduler.ScheduleAbsolute(510, () => Checkpoint(engine, store)); Scheduler.ScheduleAbsolute(600, () => RemoveQueryEngine(engine)); Scheduler.ScheduleAbsolute(800, () => Recover(CreateQueryEngine(), store)); Scheduler.Start(); var sub = GetTestableSubscribable <int>("source"); sub.Subscriptions.AssertEqual( ReactiveTest.Subscribe(10, 10 + 540), ReactiveTest.Subscribe(800, 800 + 540)); var res = GetTestableObserver <int>("result"); res.Messages.AssertEqual( OnNext(110, 1), OnNext(210, 2), OnNext(310, 3), OnNext(410, 4), OnNext(500, 5), OnError <int>(550, ex => ex is DivideByZeroException), OnError <int>(800 + 540, ex => ex is DivideByZeroException)); }
public void Remoting_VirtualTimeTest_Sample() { using var client = CreateTestClient(); var xs = client.CreateHotObservable( ObserverMessage.OnNext(100, 1), ObserverMessage.OnNext(150, 2), ObserverMessage.OnNext(200, 3), ObserverMessage.OnNext(250, 4)); var res = client.Start(() => xs.Select(x => x * x), 50, 125, 225); res.Messages.AssertEqual( ObserverMessage.OnNext(150, 4), ObserverMessage.OnNext(200, 9)); xs.Subscriptions.AssertEqual( ReactiveTest.Subscribe(125, 225)); }
public void TakeWhile_SourceCompletedBeforeCheckpoint_FailAndReload() { var store = new InMemoryStateStore("someId"); var engine = CreateQueryEngine(); var reactive = engine.GetReactiveService(); var source = GetTestableQbservable(reactive, "source", OnNext(100, 1), // 110 OnNext(200, 2), // 210 OnNext(300, 3), // 310 OnNext(400, 4), // 410 OnCompleted <int>(490) // 500 // crash at 600 ); Assert.IsNotNull(source); var result = GetTestableQbserver <int>(reactive, "result"); Scheduler.ScheduleAbsolute(10, () => source.TakeWhile(i => i < 5).Subscribe(result, new Uri("s:/sub1"), null)); Scheduler.ScheduleAbsolute(510, () => Checkpoint(engine, store)); Scheduler.ScheduleAbsolute(600, () => RemoveQueryEngine(engine)); Scheduler.ScheduleAbsolute(800, () => Recover(CreateQueryEngine(), store)); Scheduler.Start(); var sub = GetTestableSubscribable <int>("source"); sub.Subscriptions.AssertEqual( ReactiveTest.Subscribe(10, 10 + 490), ReactiveTest.Subscribe(800, 800)); var res = GetTestableObserver <int>("result"); res.Messages.AssertEqual( OnNext(110, 1), OnNext(210, 2), OnNext(310, 3), OnNext(410, 4), OnCompleted <int>(500)); }
private void Then_no_projects_should_be_found() { ReactiveAssert.AreElementsEqual(new Recorded <Notification <Project> >[] { ReactiveTest.OnCompleted <Project>(350) }, _results.Messages); ReactiveAssert.AreElementsEqual(new Subscription[] { ReactiveTest.Subscribe(50, 350) }, _inputObservable.Subscriptions); }