Exemplo n.º 1
0
        public async Task given_unhandlable_message_then_sut_ignores_it(
            IEventConverter converter,
            IMessageHandler handler,
            Message message)
        {
            Mock.Get(handler).Setup(x => x.CanHandle(It.IsAny <Message>())).Returns(false);
            EventProcessor sut       = new EventProcessorBuilder(converter, handler).Build();
            EventData      eventData = converter.ConvertToEvent(message);

            await sut.Process(new[] { eventData });

            Mock.Get(handler).Verify(x => x.Handle(It.IsAny <Message>()), Times.Never());
        }
Exemplo n.º 2
0
        public async Task given_unknown_type_then_sut_ignores_message(
            IEventConverter converter,
            LoggingMessageHandler spy,
            Message message,
            string unknownType)
        {
            EventProcessor sut       = new EventProcessorBuilder(converter, spy).Build();
            EventData      eventData = converter.ConvertToEvent(message);

            eventData.Properties["Type"] = unknownType;

            await sut.Process(new[] { eventData });

            spy.Log.Should().BeEmpty();
        }
Exemplo n.º 3
0
        public async Task sut_processes_event_correctly(
            IEventConverter converter,
            LoggingMessageHandler spy,
            string id,
            MessageData1 data,
            TracingProperties tracingProperties)
        {
            EventProcessor sut       = new EventProcessorBuilder(converter, spy).Build();
            var            message   = new Message(id, data, tracingProperties);
            EventData      eventData = converter.ConvertToEvent(message);

            await sut.Process(new[] { eventData });

            spy.Log.Should().ContainSingle();
            spy.Log.Single().Should().BeEquivalentTo(message);
        }