Ejemplo n.º 1
0
        public void Should_return_first_inner_name()
        {
            A.CallTo(() => consumer1.Name).Returns("my-inner-consumer");

            var sut = new CompoundEventConsumer(consumer1, consumer2);

            Assert.Equal("my-inner-consumer", sut.Name);
        }
Ejemplo n.º 2
0
        public void Should_return_first_inner_name()
        {
            consumer1.Setup(x => x.Name).Returns("my-inner-consumer");

            var sut = new CompoundEventConsumer(consumer1.Object, consumer2.Object);

            Assert.Equal("my-inner-consumer", sut.Name);
        }
Ejemplo n.º 3
0
        public void Should_ignore_empty_filters()
        {
            A.CallTo(() => consumer1.EventsFilter).Returns("filter1");
            A.CallTo(() => consumer2.EventsFilter).Returns(string.Empty);

            var sut = new CompoundEventConsumer("my", consumer1, consumer2);

            Assert.Equal("(filter1)", sut.EventsFilter);
        }
Ejemplo n.º 4
0
        public void Should_return_compound_filter()
        {
            A.CallTo(() => consumer1.EventsFilter).Returns("filter1");
            A.CallTo(() => consumer2.EventsFilter).Returns("filter2");

            var sut = new CompoundEventConsumer("my", consumer1, consumer2);

            Assert.Equal("(filter1)|(filter2)", sut.EventsFilter);
        }
Ejemplo n.º 5
0
        public void Should_ignore_empty_filters()
        {
            consumer1.Setup(x => x.EventsFilter).Returns("filter1");
            consumer2.Setup(x => x.EventsFilter).Returns("");

            var sut = new CompoundEventConsumer("my", consumer1.Object, consumer2.Object);

            Assert.Equal("(filter1)", sut.EventsFilter);
        }
Ejemplo n.º 6
0
        public void Should_return_compound_filter()
        {
            consumer1.Setup(x => x.EventsFilter).Returns("filter1");
            consumer2.Setup(x => x.EventsFilter).Returns("filter2");

            var sut = new CompoundEventConsumer("my", consumer1.Object, consumer2.Object);

            Assert.Equal("(filter1)|(filter2)", sut.EventsFilter);
        }
Ejemplo n.º 7
0
        public async Task Should_clear_all_consumers()
        {
            consumer1.Setup(x => x.ClearAsync()).Returns(TaskHelper.Done).Verifiable();
            consumer2.Setup(x => x.ClearAsync()).Returns(TaskHelper.Done).Verifiable();

            var sut = new CompoundEventConsumer("consumer-name", consumer1.Object, consumer2.Object);

            await sut.ClearAsync();

            consumer1.VerifyAll();
            consumer2.VerifyAll();
        }
Ejemplo n.º 8
0
        public async Task Should_invoke_all_consumers()
        {
            var @event = Envelope.Create(new MyEvent());

            consumer1.Setup(x => x.On(@event)).Returns(TaskHelper.Done).Verifiable();
            consumer2.Setup(x => x.On(@event)).Returns(TaskHelper.Done).Verifiable();

            var sut = new CompoundEventConsumer("consumer-name", consumer1.Object, consumer2.Object);

            await sut.On(@event);

            consumer1.VerifyAll();
            consumer2.VerifyAll();
        }
Ejemplo n.º 9
0
        public async Task Should_clear_all_consumers()
        {
            A.CallTo(() => consumer1.ClearAsync()).
            Returns(TaskHelper.Done);

            A.CallTo(() => consumer2.ClearAsync())
            .Returns(TaskHelper.Done);

            var sut = new CompoundEventConsumer("consumer-name", consumer1, consumer2);

            await sut.ClearAsync();

            A.CallTo(() => consumer1.ClearAsync()).MustHaveHappened();
            A.CallTo(() => consumer2.ClearAsync()).MustHaveHappened();
        }
Ejemplo n.º 10
0
        public async Task Should_invoke_all_consumers()
        {
            var @event = Envelope.Create(new MyEvent());

            A.CallTo(() => consumer1.On(@event))
            .Returns(TaskHelper.Done);

            A.CallTo(() => consumer2.On(@event))
            .Returns(TaskHelper.Done);

            var sut = new CompoundEventConsumer("consumer-name", consumer1, consumer2);

            await sut.On(@event);

            A.CallTo(() => consumer1.On(@event)).MustHaveHappened();
            A.CallTo(() => consumer2.On(@event)).MustHaveHappened();
        }
Ejemplo n.º 11
0
        public void Should_return_given_name()
        {
            var sut = new CompoundEventConsumer("consumer-name", consumer1);

            Assert.Equal("consumer-name", sut.Name);
        }
Ejemplo n.º 12
0
        public void Should_return_first_inner_name()
        {
            var sut = new CompoundEventConsumer(consumer1.Object, consumer2.Object);

            Assert.Equal(consumer1.Object.GetType().Name, sut.Name);
        }