public void Can_enumerate_catalog() { var subject = new Subject <Device>(); var catalog = new DeviceCatalog(subject, NullLogger <DeviceCatalog> .Instance); subject.OnNext(TestMessages.NewSearchResponse() with { Id = 7 });
public void Monitor_publishes_devices_to_observers() { var observed = new List <Device>(); var monitor = new MessagePublisher <Device>(); monitor.Subscribe(observed.Add); monitor.Publish(TestMessages.NewSearchResponse()); observed.Count.Should().Be(1); }
public void Monitor_subscription_disposal_stops_subscription() { var observed = new List <Device>(); var monitor = new MessagePublisher <Device>(); using (var _ = monitor.Subscribe(observed.Add)) { monitor.Publish(TestMessages.NewSearchResponse()); } monitor.Publish(TestMessages.NewSearchResponse()); observed.Count.Should().Be(1); }
public void Catalog_can_turn_stream_of_messages_into_devices() { var subject = new Subject <Device>(); var catalog = new DeviceCatalog(subject, NullLogger <DeviceCatalog> .Instance); subject.OnNext(TestMessages.NewSearchResponse()); subject.OnNext(TestMessages.NewSearchResponse()); var device = TestMessages.NewSearchResponse(); subject.OnNext(device); subject.OnNext(device); catalog.Count.Should().Be(3); }