示例#1
0
        public async Task When_depositing_a_message_in_the_outbox()
        {
            //act
            var postedMessageId = await _commandProcessor.DepositPostAsync(_myCommand);

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

            //message should be in the store
            var depositedPost = _fakeOutboxSync
                                .OutstandingMessages(0)
                                .SingleOrDefault(msg => msg.Id == _message.Id);

            depositedPost.Should().NotBeNull();

            //message should correspond to the command
            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 = await _fakeOutboxSync.OutstandingMessagesAsync(0);

            var outstandingMessage = outstandingMessages.Single();

            outstandingMessage.Id.Should().Be(_message.Id);
        }
        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);
        }