Пример #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);
        }
Пример #2
0
        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
            _fakeMessageStore.MessageWasAdded.Should().BeTrue();
            //message should not be posted
            _fakeMessageProducer.MessageWasSent.Should().BeFalse();

            //message should correspond to the command
            var depositedPost = _fakeMessageStore.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 async Task When_depositing_a_message_in_the_outbox()
        {
            //act
            var postedMessageId = await _commandProcessor.DepositPostAsync(_myCommand);

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

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

            depositedPost.Should().NotBe(null);

            //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);
        }