TestServer Class

Definition

An IServer implementation for executing tests.

public ref class TestServer : IDisposable, Microsoft::AspNetCore::Hosting::Server::IServer
public class TestServer : IDisposable, Microsoft.AspNetCore.Hosting.Server.IServer
type TestServer = class
    interface IServer
    interface IDisposable
Public Class TestServer
Implements IDisposable, IServer
Inheritance
TestServer
Implements

Constructors

TestServer(IServiceProvider)

For use with IHostBuilder.

TestServer(IServiceProvider, IFeatureCollection)

For use with IHostBuilder.

TestServer(IServiceProvider, IFeatureCollection, IOptions<TestServerOptions>)

For use with IHostBuilder.

TestServer(IServiceProvider, IOptions<TestServerOptions>)

For use with IHostBuilder.

TestServer(IWebHostBuilder)

For use with IWebHostBuilder.

TestServer(IWebHostBuilder, IFeatureCollection)

For use with IWebHostBuilder.

Properties

AllowSynchronousIO

Gets or sets a value that controls whether synchronous IO is allowed for the Request and Response. The default value is false.

BaseAddress

Gets or sets the base address associated with the HttpClient returned by the test server. Defaults to http://localhost/.

Features

Gets the collection of server features associated with the test server.

Host

Gets the IWebHost instance associated with the test server.

PreserveExecutionContext

Gets or sets a value that controls if ExecutionContext and AsyncLocal<T> values are preserved from the client to the server. The default value is false.

Services

Gets the service provider associated with the test server.

Methods

CreateClient()

Creates a HttpClient for processing HTTP requests/responses with the test server.

CreateHandler()

Creates a custom HttpMessageHandler for processing HTTP requests/responses with the test server.

CreateRequest(String)

Begins constructing a request message for submission.

CreateWebSocketClient()

Creates a WebSocketClient for interacting with the test server.

Dispose()

Dispoes the IWebHost object associated with the test server.

SendAsync(Action<HttpContext>, CancellationToken)

Creates, configures, sends, and returns a HttpContext. This completes as soon as the response is started.

Explicit Interface Implementations

IServer.Features
IServer.Start<TContext>(IHttpApplication<TContext>)
IServer.StartAsync<TContext>(IHttpApplication<TContext>, CancellationToken)
IServer.StopAsync(CancellationToken)

Applies to