コード例 #1
0
        internal virtual async Task RunMultiStreamTest(Func <HttpConnection, Uri, Task> clientFunc, Func <HttpTestConnection, Task> serverFunc, int?millisecondsTimeout = null)
        {
            ConnectionFactory connectionFactory = CreateConnectionFactory();

            await using (connectionFactory.ConfigureAwait(false))
            {
                var server = await CreateTestServerAsync(connectionFactory);

                await using (server.ConfigureAwait(false))
                {
                    await RunClientServer(RunClientAsync, RunServerAsync, millisecondsTimeout).ConfigureAwait(false);

                    async Task RunClientAsync()
                    {
                        HttpConnection httpConnection = await CreateTestClientAsync(connectionFactory, server.EndPoint !).ConfigureAwait(false);

                        await using (httpConnection.ConfigureAwait(false))
                        {
                            await clientFunc(httpConnection, server.Uri).ConfigureAwait(false);
                        }
                    }

                    async Task RunServerAsync()
                    {
                        HttpTestConnection connection = await server.AcceptAsync().ConfigureAwait(false);

                        await using (connection.ConfigureAwait(false))
                        {
                            await serverFunc(connection).ConfigureAwait(false);
                        }
                    }
                }
            }
        }