Beispiel #1
0
        public async Task Sent_events_are_received([Frozen] IEnvelopeService envelopeService, InMemoryBusEngine sut, EventMessage <FirstTestEvent> testMessage, IFixture fixture, string headerKey, string headerValue)
        {
            fixture.Customize <Envelope>(c => c
                                         .With(p => p.Type, testMessage.Type)
                                         .With(p => p.Headers, testMessage.Headers)
                                         .With(p => p.Content)
                                         .With(p => p.MessageId, testMessage.MessageId)
                                         .With(p => p.MessageType, testMessage.MessageType)
                                         );

            Mock.Get(envelopeService).Setup(p => p.CreateEnvelope(It.IsAny <EventMessage <FirstTestEvent> >())).ReturnsUsingFixture(fixture);
            Mock.Get(envelopeService).Setup(p => p.CreateEventMessage(It.IsAny <Envelope>(), It.IsAny <Type>())).Returns(testMessage);

            testMessage.Headers[headerKey] = headerValue;

            sut.SubscribeToEvent <FirstTestEvent>();

            var sequence = await sut.StartAsync().ConfigureAwait(false);

            var items = sequence.DumpInList();

            await sut.SendMessageAsync(testMessage);

            Assert.That(items.First().Headers, Contains.Key(headerKey));
            Assert.That(items.First().Headers[headerKey], Is.EqualTo(headerValue));
        }
Beispiel #2
0
        public void SubscribeToEvent_adds_type_AcceptedTypes_list(InMemoryBusEngine sut)
        {
            sut.SubscribeToEvent <FirstTestEvent>();

            Assert.That(sut.IsTypeAccepted(typeof(FirstTestEvent)));
        }