public void Subscribe_ShouldThrowArgumentException_WhenSubscribersIsEmpty() { var bus = new ReactiveBus(this.mockedQueue.Object); Assert.NotNull(bus); Assert.Throws <ArgumentException>(() => bus.Subscribe(new List <ISubscriber>())); }
public void Publish_ShouldThrowArgumentNullException_WhenItemIsNull() { var bus = new ReactiveBus(this.mockedQueue.Object); Assert.NotNull(bus); Assert.Throws <ArgumentNullException>(() => bus.Publish(null)); }
public void Subscribe_ShouldSuccessfullySubscribeSubscribers() { this.mockedQueue.Setup(m => m.Subscribe(It.IsAny <IObserver <string> >())); var bus = new ReactiveBus(this.mockedQueue.Object); bus.Subscribe(GetMockedSubscribers()); this.mockedQueue.Verify(m => m.Subscribe(It.IsAny <IObserver <string> >()), Times.Exactly(2)); }
public void Publish_ShouldSuccessfullyPublishItem() { this.mockedQueue.Setup(m => m.OnNext(Message)); var bus = new ReactiveBus(this.mockedQueue.Object); bus.Publish(Message); Assert.NotNull(bus); this.mockedQueue.Verify(m => m.OnNext(Message), Times.Once); }
public void ShouldSuccessfullyPublishAndSubscribe() { var subject = new Subject <string>(); var mockedSubscriber = new Mock <ISubscriber>(); var bus = new ReactiveBus(subject); bus.Subscribe(new List <ISubscriber> { mockedSubscriber.Object }); bus.Publish(Message); mockedSubscriber.Verify(m => m.Subscribe(Message), Times.Once); }