Class KestrelWebApplicationFactory<TEntryPoint>
Inheritance
Implements
Namespace: Accelergreat.Web.Factories
Assembly: Accelergreat.Web.dll
Syntax
public class KestrelWebApplicationFactory<TEntryPoint> : IDisposable where TEntryPoint : class
Type Parameters
Name | Description |
---|---|
TEntryPoint |
Properties
ConfigureHttpsPort
Declaration
protected bool ConfigureHttpsPort { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Server
Gets the Microsoft.AspNetCore.Hosting.Server.IServer created by this Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint>.
Declaration
public IServer Server { get; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Hosting.Server.IServer |
Services
Gets the
Declaration
public virtual IServiceProvider? Services { get; }
Property Value
Type | Description |
---|---|
System.Nullable<IServiceProvider> |
Methods
ConfigureClient(HttpClient)
Configures
Declaration
protected virtual void ConfigureClient(HttpClient client)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | client | The |
ConfigureWebHost(IWebHostBuilder)
Gives a fixture an opportunity to configure the application before it gets built.
Declaration
protected virtual void ConfigureWebHost(IWebHostBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Hosting.IWebHostBuilder | builder | The Microsoft.AspNetCore.Hosting.IWebHostBuilder for the application. |
CreateClient()
Creates an instance of
Declaration
public HttpClient CreateClient()
Returns
Type | Description |
---|---|
HttpClient | The |
CreateClient(KestrelWebApplicationFactoryClientOptions)
Creates an instance of
Declaration
public HttpClient CreateClient(KestrelWebApplicationFactoryClientOptions options)
Parameters
Type | Name | Description |
---|---|---|
KestrelWebApplicationFactoryClientOptions | options |
Returns
Type | Description |
---|---|
HttpClient | The |
CreateDefaultClient(DelegatingHandler[])
Creates a new instance of an
Declaration
public HttpClient CreateDefaultClient(params DelegatingHandler[] handlers)
Parameters
Type | Name | Description |
---|---|---|
DelegatingHandler[] | handlers | A list of |
Returns
Type | Description |
---|---|
HttpClient | The |
CreateHost(IHostBuilder)
Creates the Microsoft.Extensions.Hosting.IHost with the bootstrapped application in builder
.
This is only called for applications using Microsoft.Extensions.Hosting.IHostBuilder. Applications based on
Microsoft.AspNetCore.Hosting.IWebHostBuilder will use CreateWebHost(IWebHostBuilder) instead.
Declaration
protected virtual IHost CreateHost(IHostBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Hosting.IHostBuilder | builder | The Microsoft.Extensions.Hosting.IHostBuilder used to create the host. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.Hosting.IHost | The Microsoft.Extensions.Hosting.IHost with the bootstrapped application. |
CreateWebHost(IWebHostBuilder)
Creates the Microsoft.AspNetCore.Hosting.IWebHost with the bootstrapped application in builder
.
This is only called for applications using Microsoft.Extensions.Hosting.IHostBuilder. Applications based on
Microsoft.Extensions.Hosting.IHostBuilder will use CreateHost(IHostBuilder) instead.
Declaration
protected virtual IWebHost CreateWebHost(IWebHostBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Hosting.IWebHostBuilder | builder | The Microsoft.Extensions.Hosting.IHostBuilder used to create the host. |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Hosting.IWebHost | The Microsoft.Extensions.Hosting.IHost with the bootstrapped application. |
CreateWebHostBuilder()
Creates a Microsoft.AspNetCore.Hosting.IWebHostBuilder used to set up Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.
Declaration
protected virtual IWebHostBuilder CreateWebHostBuilder()
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Hosting.IWebHostBuilder | A Microsoft.AspNetCore.Hosting.IWebHostBuilder instance. |
Remarks
The default implementation of this method looks for a public static IWebHostBuilder CreateWebHostBuilder(string[] args)
method defined on the entry point of the assembly of TEntryPoint
and invokes it passing an empty string
array as arguments.
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
DisposeAsync()
Declaration
public virtual async ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
Finalize()
Finalizes an instance of the KestrelWebApplicationFactory<TEntryPoint> class.
Declaration
protected void Finalize()
GetBaseAddress(Boolean)
Declaration
public string GetBaseAddress(bool preferHttps = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | preferHttps |
Returns
Type | Description |
---|---|
System.String |
GetTestAssemblies()
Gets the assemblies containing the functional tests. The
Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactoryContentRootAttribute applied to these
assemblies defines the content root to use for the given
TEntryPoint
.
Declaration
protected virtual IEnumerable<Assembly> GetTestAssemblies()
Returns
Type | Description |
---|---|
IEnumerable<System.Reflection.Assembly> | The list of System.Reflection.Assembly containing tests. |