Class AppFixture<TProgram>
inherit this class to create a class fixture for an implementation of TestBase<TAppFixture>.
Inherited Members
Namespace: FastEndpoints.Testing
Assembly: FastEndpoints.Testing.dll
Syntax
public abstract class AppFixture<TProgram> : BaseFixture, IFaker, IAsyncLifetime, IAsyncDisposable where TProgram : class
Type Parameters
Name | Description |
---|---|
TProgram | the type of the web application to bootstrap via WebApplicationFactory<TEntryPoint> |
Properties
Client
the default http client
Declaration
public HttpClient Client { get; set; }
Property Value
Type | Description |
---|---|
HttpClient |
Server
the test server of the underlying WebApplicationFactory<TEntryPoint>
Declaration
public TestServer Server { get; }
Property Value
Type | Description |
---|---|
TestServer |
Services
the service provider of the bootstrapped web application
Declaration
public IServiceProvider Services { get; }
Property Value
Type | Description |
---|---|
IServiceProvider |
Methods
ConfigureApp(IWebHostBuilder)
override this method if you'd like to provide any configuration for the web host of the underlying WebApplicationFactory<TEntryPoint> />
Declaration
protected virtual void ConfigureApp(IWebHostBuilder a)
Parameters
Type | Name | Description |
---|---|---|
IWebHostBuilder | a |
ConfigureAppHost(IHostBuilder)
override this method if you'd like to provide any configuration for the generic app host of the underlying WebApplicationFactory<TEntryPoint>
Declaration
protected virtual IHost ConfigureAppHost(IHostBuilder a)
Parameters
Type | Name | Description |
---|---|---|
IHostBuilder | a |
Returns
Type | Description |
---|---|
IHost |
ConfigureServices(IServiceCollection)
override this method if you'd like to override (remove/replace) any services registered in the underlying web application's DI container.
Declaration
protected virtual void ConfigureServices(IServiceCollection s)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | s |
CreateClient(ClientOptions?)
create a client for the underlying web application
Declaration
public HttpClient CreateClient(ClientOptions? o = null)
Parameters
Type | Name | Description |
---|---|---|
ClientOptions | o | optional client options for the WAF |
Returns
Type | Description |
---|---|
HttpClient |
CreateClient(Action<HttpClient>, ClientOptions?)
create a client for the underlying web application
Declaration
public HttpClient CreateClient(Action<HttpClient> c, ClientOptions? o = null)
Parameters
Type | Name | Description |
---|---|---|
Action<HttpClient> | c | configuration action for the client |
ClientOptions | o | optional client options for the WAF |
Returns
Type | Description |
---|---|
HttpClient |
CreateHandler(Action<HttpContext>?)
create a http message handler for the underlying web host/test server
Declaration
public HttpMessageHandler CreateHandler(Action<HttpContext>? c = null)
Parameters
Type | Name | Description |
---|---|---|
Action<HttpContext> | c |
Returns
Type | Description |
---|---|
HttpMessageHandler |
PreSetupAsync()
this will be called before the WAF is initialized. override this method if you'd like to do something before the WAF is initialized that is going to contribute to the creation of the WAF, such as initialization of a 'TestContainer'.
Declaration
protected virtual ValueTask PreSetupAsync()
Returns
Type | Description |
---|---|
ValueTask |
SetupAsync()
override this method if you'd like to do some one-time setup for the fixture. it is run before any of the test-methods of the class is executed, but after the WAF is initialized.
Declaration
protected virtual ValueTask SetupAsync()
Returns
Type | Description |
---|---|
ValueTask |
TearDownAsync()
override this method if you'd like to do some one-time teardown for the fixture. it is run after all test-methods have executed.
Declaration
protected virtual ValueTask TearDownAsync()
Returns
Type | Description |
---|---|
ValueTask |