Beispiel #1
0
        public void When_Posting_A_Message_To_The_Command_Processor()
        {
            _commandProcessor.Post(_myCommand);

            //_should_store_the_message_in_the_message_store
            _fakeOutbox
            .Get()
            .SingleOrDefault(msg => msg.Id == _message.Id)
            .Should().NotBeNull();
            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducerWithPublishConfirmation.MessageWasSent.Should().BeTrue();
            //_should_convert_the_command_into_a_message
            _fakeOutbox.Get().First().Should().Be(_message);
        }
Beispiel #2
0
        public async Task When_Posting_A_Message_To_The_Command_Processor_Async()
        {
            await _commandProcessor.PostAsync(_myCommand);

            //_should_store_the_message_in_the_sent_command_message_repository
            _fakeOutboxSync
            .Get()
            .SingleOrDefault(msg => msg.Id == _message.Id)
            .Should().NotBeNull();
            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducerWithPublishConfirmation.MessageWasSent.Should().BeTrue();
            //_should_convert_the_command_into_a_message
        }
        public void When_depositing_a_message_in_the_outbox()
        {
            //act
            var postedMessageId = _commandProcessor.DepositPost(_myCommand);

            //assert

            //message should not be posted
            _fakeMessageProducerWithPublishConfirmation.MessageWasSent.Should().BeFalse();

            //message should correspond to the command
            var depositedPost = _fakeOutbox.Get(postedMessageId);

            depositedPost.Id.Should().Be(_message.Id);
            depositedPost.Body.Value.Should().Be(_message.Body.Value);
            depositedPost.Header.Topic.Should().Be(_message.Header.Topic);
            depositedPost.Header.MessageType.Should().Be(_message.Header.MessageType);

            //message should be marked as outstanding if not sent
            var outstandingMessages = _fakeOutbox.OutstandingMessages(0);
            var outstandingMessage  = outstandingMessages.Single();

            outstandingMessage.Id.Should().Be(_message.Id);
        }