private async Task <MessageWaiter <T> > PublishRealMessage <T>(T testMessage, MessageProperties messageProperties, IMessageGenerator messageGenerator)
        {
            messageGenerator = messageGenerator ?? new MessageGenerator();
            var messagePublisher = new MessagePublisher(
                _serviceProvider.GetService <IMessageSender>(),
                messageGenerator,
                new MessageProperties(_serviceProvider.GetService <ICorrelationIdProvider>()));

            var messageWaiter = new MessageWaiter <T>(
                _serviceProvider.GetService <MessageReceivedNotifier <T> >(),
                capturedEvent => capturedEvent.CorrelationId == messageProperties.CorrelationIdProvider.CorrelationId);

            await messagePublisher.PublishEvent(testMessage, messageProperties).ConfigureAwait(false);

            return(messageWaiter);
        }
        private Task <MessageWaiter <T> > PublishFakeMessage <T>(T testMessage, MessageProperties messageProperties, IMessageGenerator messageGenerator)
        {
            messageGenerator = messageGenerator ?? new MessageGenerator();
            var messageReceiver = _serviceProvider.GetService <IMessageReceiver>();

            messageReceiver.ReceiveAsync(0, TimeSpan.MaxValue).ReturnsForAnyArgs(info =>
                                                                                 new List <Message>()
            {
                MessageHelper.GenerateMessage(testMessage, messageProperties, messageGenerator)
            });

            var messageWaiter = new MessageWaiter <T>(
                _serviceProvider.GetService <MessageReceivedNotifier <T> >(),
                capturedEvent => capturedEvent.CorrelationId == messageProperties.CorrelationIdProvider.CorrelationId);

            return(Task.FromResult(messageWaiter));
        }