Exemplo n.º 1
0
        public async Task Sent_commands_are_received([Frozen] IEnvelopeService envelopeService, InMemoryBusEngine sut, CommandMessage <FirstTestCommand> 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 <CommandMessage <FirstTestCommand> >())).ReturnsUsingFixture(fixture);
            Mock.Get(envelopeService).Setup(p => p.CreateCommandMessage(It.IsAny <Envelope>(), It.IsAny <Type>())).Returns(testMessage);

            testMessage.Headers[headerKey] = headerValue;

            sut.SubscribeToCommand <FirstTestCommand>();

            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));
        }
Exemplo n.º 2
0
        public void SubscribeToCommand_adds_type_to_AcceptedTypes_list(InMemoryBusEngine sut)
        {
            sut.SubscribeToCommand <FirstTestCommand>();

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