private static async Task <WebSocketConnectionSummary> RunReceiveTest(Func <IWritableChannel, CancellationToken, Task> producer)
        {
            using (var factory = new ChannelFactory())
            {
                var outbound = factory.CreateChannel();
                var inbound  = factory.CreateChannel();

                var timeoutToken = TestUtil.CreateTimeoutToken();

                var producerTask = Task.Run(async() =>
                {
                    await producer(inbound, timeoutToken).OrTimeout();
                    inbound.CompleteWriter();
                }, timeoutToken);

                var consumerTask = Task.Run(async() =>
                {
                    var connection = new WebSocketConnection(inbound, outbound, options: new WebSocketOptions().WithAllFramesPassedThrough());
                    using (timeoutToken.Register(() => connection.Dispose()))
                        using (connection)
                        {
                            // Receive frames until we're closed
                            return(await connection.ExecuteAndCaptureFramesAsync().OrTimeout());
                        }
                }, timeoutToken);

                await Task.WhenAll(producerTask, consumerTask);

                return(consumerTask.Result);
            }
        }