public void Should_create_a_hot_observable() { var expected = new[] { "A", "B" }; var source = _scheduler.CreateHotObservable <string>("--a---b--|", new { a = "A", b = "B" }); var i = 0; source.Subscribe(x => Check.That(x).IsEqualTo(expected[i++])); _scheduler.Start(); Check.That(i).IsEqualTo(2); }
public void Should_use_unsubscription_diagram() { var scheduler = new MarbleScheduler(); var source = scheduler.CreateHotObservable("---^-a-b-|"); var unsubscribe = "---!"; var expected = "--a"; scheduler.ExpectObservable(source, unsubscribe).ToBe(expected); scheduler.Flush(); }
public void Should_support_testing_metastreams() { var scheduler = new MarbleScheduler(); var x = scheduler.CreateColdObservable("-a-b|"); var y = scheduler.CreateColdObservable("-c-d|"); var myObservable = scheduler.CreateHotObservable <IObservable <string> >("---x---y----|", new { x = x, y = y }); var expected = "---x---y----|"; var expectedx = scheduler.CreateColdObservable("-a-b|"); var expectedy = scheduler.CreateColdObservable("-c-d|"); scheduler.ExpectObservable(myObservable).ToBe(expected, new { x = expectedx, y = expectedy }); scheduler.Flush(); }
public async Task should_forward_forex_data() { // given var scheduler = new MarbleScheduler(); var forexSource = scheduler.CreateHotObservable <string>("--f--", new { f = new Quote("EUR/USD", 1.4).ToJson() }); // when var forexStream = await Create(forexSource).GetEvents(); // then scheduler.ExpectObservable(forexStream.Take(1)) .ToBe("--(v|)", new { v = 1.4 }); scheduler.Flush(); }
public async Task should_send_a_stock_message_when_receiving_a_quote() { // given var scheduler = new MarbleScheduler(); var quoteSource = scheduler.CreateHotObservable <string>("--q--", new { q = new Quote("GOOGL", 705.8673).ToJson() }); // when var server = CreateServer(quoteSource, scheduler); var stream = await server.GetEvents(); // then scheduler.ExpectObservable(stream.Select(s => s.CompanyName).Concat(Observable.Never <string>())) .ToBe("--s--", new { s = "Alphabet Inc" }); scheduler.Flush(); }
public async Task should_send_a_stock_message_only_once_when_receiving_two_quotes_for_the_same_stock() { // given var scheduler = new MarbleScheduler(); var quoteSource = scheduler.CreateHotObservable <string>("--f-s-t--", new { f = new Quote("GOOGL", 705.8673).ToJson(), s = new Quote("GOOGL", 705.8912).ToJson(), t = new Quote("IBM", 106.344).ToJson() }); // when var server = CreateServer(quoteSource, scheduler); var stream = await server.GetEvents(); // then scheduler.ExpectObservable(stream.Select(s => s.CompanyName).Concat(Observable.Never <string>())) .ToBe("--g---i--", new { g = "Alphabet Inc", i = "International Business Machines Corp." }); scheduler.Flush(); }