WebApplicationFactory<TEntryPoint> Class
Definition
Factory for bootstrapping an application in memory for functional end to end tests.
generic <typename TEntryPoint>
where TEntryPoint : classpublic ref class WebApplicationFactory : IDisposable
public class WebApplicationFactory<TEntryPoint> : IDisposable where TEntryPoint : class
type WebApplicationFactory<'EntryPoint (requires 'EntryPoint : null)> = class
interface IDisposable
Public Class WebApplicationFactory(Of TEntryPoint)
Implements IDisposable
Type Parameters
- TEntryPoint
A type in the entry point assembly of the application. Typically the Startup or Program classes can be used.
- Inheritance
-
WebApplicationFactory<TEntryPoint>
- Implements
Constructors
WebApplicationFactory<TEntryPoint>() |
Creates an instance of WebApplicationFactory<TEntryPoint>. This factory can be used to
create a TestServer instance using the MVC application defined by
This constructor will infer the application content root path by searching for a
WebApplicationFactoryContentRootAttribute on the assembly containing the functional tests with
a key equal to the
The application assemblies will be loaded from the dependency context of the assembly containing
|
Properties
ClientOptions |
Gets the WebApplicationFactoryClientOptions used by CreateClient(). |
Factories |
Gets the IReadOnlyList<T> of factories created from this factory by further customizing the IWebHostBuilder when calling WithWebHostBuilder(Action<IWebHostBuilder>). |
Server |
Gets the TestServer created by this WebApplicationFactory<TEntryPoint>. |
Services |
Gets the IServiceProvider created by the server associated with this WebApplicationFactory<TEntryPoint>. |
Methods
ConfigureClient(HttpClient) |
Configures HttpClient instances created by this WebApplicationFactory<TEntryPoint>. |
ConfigureWebHost(IWebHostBuilder) |
Gives a fixture an opportunity to configure the application before it gets built. |
CreateClient() |
Creates an instance of HttpClient that automatically follows redirects and handles cookies. |
CreateClient(WebApplicationFactoryClientOptions) |
Creates an instance of HttpClient that automatically follows redirects and handles cookies. |
CreateDefaultClient(DelegatingHandler[]) |
Creates a new instance of an HttpClient that can be used to
send HttpRequestMessage to the server. The base address of the HttpClient
instance will be set to |
CreateDefaultClient(Uri, DelegatingHandler[]) |
Creates a new instance of an HttpClient that can be used to send HttpRequestMessage to the server. |
CreateHost(IHostBuilder) |
Creates the IHost with the bootstrapped application in |
CreateHostBuilder() |
Creates a IHostBuilder used to set up TestServer. |
CreateServer(IWebHostBuilder) |
Creates the TestServer with the bootstrapped application in |
CreateWebHostBuilder() |
Creates a IWebHostBuilder used to set up TestServer. |
Dispose() | |
Dispose(Boolean) |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
Finalize() |
Finalizes an instance of the WebApplicationFactory<TEntryPoint> class. |
GetTestAssemblies() |
Gets the assemblies containing the functional tests. The
WebApplicationFactoryContentRootAttribute applied to these
assemblies defines the content root to use for the given
|
WithWebHostBuilder(Action<IWebHostBuilder>) |
Creates a new WebApplicationFactory<TEntryPoint> with a IWebHostBuilder
that is further customized by |