Esempio n. 1
0
        public void Subscribe_ShouldThrowArgumentException_WhenSubscribersIsEmpty()
        {
            var bus = new ReactiveBus(this.mockedQueue.Object);

            Assert.NotNull(bus);
            Assert.Throws <ArgumentException>(() => bus.Subscribe(new List <ISubscriber>()));
        }
Esempio n. 2
0
        public void Publish_ShouldThrowArgumentNullException_WhenItemIsNull()
        {
            var bus = new ReactiveBus(this.mockedQueue.Object);

            Assert.NotNull(bus);
            Assert.Throws <ArgumentNullException>(() => bus.Publish(null));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }