src/packages/EmbedIO.Testing/TestWebServer.cs
/// <summary>
/// Asynchronously create and use a <see cref="TestWebServer"/>.
/// </summary>
/// <param name="configure">A callback used to configure the server.</param>
/// <param name="use">A callback used to pass requests to the server.</param>
/// <returns>A <see cref="Task"/> that represents the ongoing operation.</returns>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="configure"/> is <see langword="null"/>.</para>
/// <para>- or -</para>
/// <para><paramref name="use"/> is <see langword="null"/>.</para>
/// </exception>
Asynchronously create and use a .
Asynchronously create and use a .
public static async Task UseAsync(Action<IWebServer> configure, Func<HttpClient, Task> use)
        {
            Validate.NotNull(nameof(configure), configure);
            Validate.NotNull(nameof(use), use);
            using var server = new TestWebServer();
            configure(server);
            using var cancellationTokenSource = new CancellationTokenSource();
            server.Start(cancellationTokenSource.Token);
            await use(server.Client).ConfigureAwait(false);
            cancellationTokenSource.Cancel();
        }
public static async Task UseAsync ( Action < IWebServer > configure , Func < HttpClient , Task > use ) { Validate . NotNull ( nameof ( configure ) , configure ) ; Validate . NotNull ( nameof ( use ) , use ) ; using var server = new TestWebServer ( ) ; configure ( server ) ; using var cancellationTokenSource = new CancellationTokenSource ( ) ; server . Start ( cancellationTokenSource . Token ) ; await use ( server . Client ) . ConfigureAwait ( false ) ; cancellationTokenSource . Cancel ( ) ; }
Asynchronously create and use a .
Asynchronously create and use a .
A  that represents the ongoing operation.
A that represents the ongoing operation .
None
configure
Action<IWebServer>
A callback used to configure the server.
A callback used to configure the server .
use
Func<HttpClient, Task>
A callback used to pass requests to the server.
A callback used to pass requests to the server .