public async Task LongPollingTransportDispatchesMessagesReceivedFromPoll()
        {
            var message1Payload = new byte[] { (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o' };

            var firstCall       = true;
            var mockHttpHandler = new Mock <HttpMessageHandler>();
            var sentRequests    = new List <HttpRequestMessage>();

            mockHttpHandler.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>())
            .Returns <HttpRequestMessage, CancellationToken>(async(request, cancellationToken) =>
            {
                sentRequests.Add(request);

                await Task.Yield();

                if (firstCall)
                {
                    firstCall = false;
                    return(ResponseUtils.CreateResponse(HttpStatusCode.OK, message1Payload));
                }

                return(ResponseUtils.CreateResponse(HttpStatusCode.NoContent));
            });

            using (var httpClient = new HttpClient(mockHttpHandler.Object))
            {
                var longPollingTransport = new LongPollingTransport(httpClient);
                try
                {
                    var connectionToTransport = Channel.CreateUnbounded <SendMessage>();
                    var transportToConnection = Channel.CreateUnbounded <byte[]>();
                    var channelConnection     = new ChannelConnection <SendMessage, byte[]>(connectionToTransport, transportToConnection);

                    // Start the transport
                    await longPollingTransport.StartAsync(new Uri("http://fakeuri.org"), channelConnection, TransferMode.Binary, connection : new TestConnection());

                    // Wait for the transport to finish
                    await longPollingTransport.Running.OrTimeout();

                    // Pull Messages out of the channel
                    var messages = new List <byte[]>();
                    while (await transportToConnection.Reader.WaitToReadAsync())
                    {
                        while (transportToConnection.Reader.TryRead(out var message))
                        {
                            messages.Add(message);
                        }
                    }

                    // Check the provided request
                    Assert.Equal(2, sentRequests.Count);

                    // Check the messages received
                    Assert.Single(messages);
                    Assert.Equal(message1Payload, messages[0]);
                }
                finally
                {
                    await longPollingTransport.StopAsync();
                }
            }
        }