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().NotBe(null);
            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();
            //_should_convert_the_command_into_a_message
            _fakeOutbox.Get().First().Should().Be(_message);
        }
示例#2
0
        public void When_Posting_A_Message_To_The_Command_Processor()
        {
            _commandProcessor.Post(_myCommand);

            //_should_store_the_message_in_the_outbox
            _fakeOutbox.MessageWasAdded.Should().BeTrue();
            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();
            //_should_convert_the_command_into_a_message
            _fakeOutbox.Get().First().Should().Be(_message);
        }
示例#3
0
        public void When_Posting_Via_A_Control_Bus_Sender()
        {
            _controlBusSender.Post(_myCommand);

            //_should_store_the_message_in_the_sent_command_message_repository
            _fakeOutbox.MessageWasAdded.Should().BeTrue();
            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();
            //_should_convert_the_command_into_a_message
            _fakeOutbox.Get().First().Should().Be(_message);
        }
示例#4
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
            _fakeOutbox
            .Get()
            .SingleOrDefault(msg => msg.Id == _message.Id)
            .Should().NotBeNull();
            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();
            //_should_convert_the_command_into_a_message
        }
        public async Task When_depositing_a_message_in_the_message_store()
        {
            //act
            var postedMessageId = await _commandProcessor.DepositPostAsync(_myCommand);

            //assert
            //message should be in the store
            _fakeOutbox.MessageWasAdded.Should().BeTrue();
            //message should not be posted
            _fakeMessageProducer.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);
        }
        public void When_depositing_a_message_in_the_outbox()
        {
            //act
            var postedMessageId = _commandProcessor.DepositPost(_myCommand);

            //assert

            //message should not be posted
            _fakeMessageProducer.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(1000);
            var outstandingMessage  = outstandingMessages.Single();

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