public async Task ResendOfOriginalMessageDoesntResultInReprocessing()
        {
            var allMessagesReceived              = new ManualResetEvent(false);
            var myMessageHandlersTriggered       = new ConcurrentQueue <DateTime>();
            var outgoingMessageHandlersTriggered = new ConcurrentQueue <OutgoingMessage>();

            _activator.Register((b, context) => new MyMessageSaga(allMessagesReceived, b, myMessageHandlersTriggered));
            _activator.Register((b, context) => new OutgoingMessageCollector(outgoingMessageHandlersTriggered));

            var msgToSend = new MyMessage
            {
                Id    = 1,
                Total = 2,
                SendOutgoingMessage = true
            };

            var headers = HeaderHelper.ConstructHeadersWithMessageId();
            await _bus.SendLocal(msgToSend, headers);

            await _bus.SendLocal(msgToSend, headers);

            await Task.Delay(1000);

            Assert.Equal(1, myMessageHandlersTriggered.Count);
            Assert.Equal(2, _transportMessagesReceived[typeof(MyMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(2, _transportMessagesReceived[typeof(OutgoingMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(2, _transportMessagesSent[typeof(MyMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(2, _transportMessagesSent[typeof(OutgoingMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(1, outgoingMessageHandlersTriggered.Count);
        }
        public async Task OutgoingMessagesAreAllRetriggeredWithMultipleHandlers(int total)
        {
            if (total < MakeEveryFifthMessageFail)
            {
                Assert.True(false, "Fail factor must be less than or equal to total!");
            }

            var myMessageHandlersTriggered        = new ConcurrentQueue <DateTime>();
            var outgoingMessageHandlersTriggered  = new ConcurrentQueue <OutgoingMessage>();
            var outgoingMessage2HandlersTriggered = new ConcurrentQueue <OutgoingMessage2>();

            _activator.Register((b, context) => new MyMessageHandler(b, myMessageHandlersTriggered));
            _activator.Register((b, context) => new MyMessageHandler2(b, myMessageHandlersTriggered));
            _activator.Register(() => new OutgoingMessageCollector(outgoingMessageHandlersTriggered));
            _activator.Register(() => new OutgoingMessage2Collector(outgoingMessage2HandlersTriggered));

            var messagesToSend = Enumerable
                                 .Range(0, total)
                                 .Select(id => new MyMessage
            {
                Id    = 1,
                Total = total,
                SendOutgoingMessage = true
            })
                                 .ToList();
            var headers = HeaderHelper.ConstructHeadersWithMessageId();

            await Task.WhenAll(messagesToSend.Select(message => _bus.SendLocal(message, headers)));

            Console.WriteLine("All messages processed - waiting for messages in outgoing message collector...");

            await Task.Delay(2000);

            Assert.Equal(2, myMessageHandlersTriggered.Count);
            Assert.Equal(total, _transportMessagesReceived[typeof(MyMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(total, _transportMessagesReceived[typeof(OutgoingMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(total, _transportMessagesReceived[typeof(OutgoingMessage2).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(total, _transportMessagesSent[typeof(MyMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(total, _transportMessagesSent[typeof(OutgoingMessage).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(total, _transportMessagesSent[typeof(OutgoingMessage2).GetSimpleAssemblyQualifiedName()]);
            Assert.Equal(1, outgoingMessageHandlersTriggered.Count);
            Assert.Equal(1, outgoingMessage2HandlersTriggered.Count);
        }