public void When_Implicit_Clearing_The_PostBox_On_The_Command_Processor()
        {
            _fakeOutbox.Add(_message);
            _fakeOutbox.Add(_message2);

            _commandProcessor.ClearOutbox(1, 1);

            for (var i = 1; i <= 10; i++)
            {
                if (_fakeMessageProducer.SentMessages.Count == 1)
                {
                    break;
                }
                Thread.Sleep(i * 100);
            }

            //Try again and kick off another background thread
            for (var i = 1; i <= 10; i++)
            {
                if (_fakeMessageProducer.SentMessages.Count == 2)
                {
                    break;
                }
                Thread.Sleep(i * 100);
                _commandProcessor.ClearOutbox(1, 1);
            }

            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();

            var sentMessage = _fakeMessageProducer.SentMessages.FirstOrDefault(m => m.Id == _message.Id);

            sentMessage.Should().NotBeNull();
            sentMessage.Id.Should().Be(_message.Id);
            sentMessage.Header.Topic.Should().Be(_message.Header.Topic);
            sentMessage.Body.Value.Should().Be(_message.Body.Value);

            var sentMessage2 = _fakeMessageProducer.SentMessages.FirstOrDefault(m => m.Id == _message2.Id);

            sentMessage2.Should().NotBeNull();
            sentMessage2.Id.Should().Be(_message2.Id);
            sentMessage2.Header.Topic.Should().Be(_message2.Header.Topic);
            sentMessage2.Body.Value.Should().Be(_message2.Body.Value);
        }
        public void When_Clearing_The_PostBox_On_The_Command_Processor()
        {
            _fakeOutbox.Add(_message);

            _commandProcessor.ClearOutbox(_message.Id);

            //_should_send_a_message_via_the_messaging_gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();

            var sentMessage = _fakeMessageProducer.SentMessages.FirstOrDefault();

            sentMessage.Should().NotBe(null);
            sentMessage.Id.Should().Be(_message.Id);
            sentMessage.Header.Topic.Should().Be(_message.Header.Topic);
            sentMessage.Body.Value.Should().Be(_message.Body.Value);
        }