Class EasyTestHostBuilder<TEntryPoint>
- Namespace
- XBullet.EasyTesting.Hosting
- Assembly
- XBullet.EasyTesting.dll
Composes configuration, services, and authentication before creating an integration-test host.
public sealed class EasyTestHostBuilder<TEntryPoint> where TEntryPoint : class
Type Parameters
TEntryPointThe application entry-point type used to locate and bootstrap the ASP.NET Core application.
- Inheritance
-
EasyTestHostBuilder<TEntryPoint>
- Inherited Members
- Extension Methods
Methods
Build()
Creates the configured application factory. A builder can be built only once.
public AuthenticatedWebApplicationFactory<TEntryPoint> Build()
Returns
- AuthenticatedWebApplicationFactory<TEntryPoint>
A new application factory owned by the caller. Dispose the factory after all clients and scenario scopes created from it have been disposed.
Exceptions
- InvalidOperationException
This builder has already been built.
ConfigureAuthentication(Action<TestAuthenticationSchemeBuilder>)
Adds a test-authentication configuration action and returns this builder.
public EasyTestHostBuilder<TEntryPoint> ConfigureAuthentication(Action<TestAuthenticationSchemeBuilder> configure)
Parameters
configureAction<TestAuthenticationSchemeBuilder>The callback invoked once before the test host is constructed. It receives the mutable authentication builder used to select simulated and end-to-end schemes. Registered callbacks run sequentially in registration order.
Returns
- EasyTestHostBuilder<TEntryPoint>
This builder so additional host behavior can be configured.
ConfigureConfiguration(Action<IConfigurationBuilder>)
Adds an application-configuration action and returns this builder.
public EasyTestHostBuilder<TEntryPoint> ConfigureConfiguration(Action<IConfigurationBuilder> configure)
Parameters
configureAction<IConfigurationBuilder>The callback invoked whenever the application factory constructs a host. It receives the host-owned configuration builder and may add or replace configuration sources. Registered callbacks run sequentially in registration order, but can run concurrently when callers construct derived factories in parallel.
Returns
- EasyTestHostBuilder<TEntryPoint>
This builder so additional host behavior can be configured.
ConfigureEnvironment(Action<TestScenarioEnvironmentBuilder>)
Adds external dependencies that are created for every test scenario.
public EasyTestHostBuilder<TEntryPoint> ConfigureEnvironment(Action<TestScenarioEnvironmentBuilder> configure)
Parameters
configureAction<TestScenarioEnvironmentBuilder>The callback invoked once for each scenario before its external resources are created. It receives that scenario's environment builder. Registered callbacks run sequentially in registration order and are not invoked concurrently by the built factory.
Returns
- EasyTestHostBuilder<TEntryPoint>
This builder so additional host behavior can be configured.
ConfigureHostSettings(Action<IDictionary<string, string>>)
Adds settings that are visible to minimal-hosting startup code as soon as
WebApplication.CreateBuilder returns.
public EasyTestHostBuilder<TEntryPoint> ConfigureHostSettings(Action<IDictionary<string, string>> configure)
Parameters
configureAction<IDictionary<string, string>>The callback invoked before minimal-hosting startup code runs for each constructed host. It receives a mutable, case-insensitive settings dictionary and may add or replace values. Registered callbacks run sequentially in registration order, but can run concurrently when callers construct derived factories in parallel.
Returns
- EasyTestHostBuilder<TEntryPoint>
This builder so additional host behavior can be configured.
ConfigureServices(Action<IServiceCollection>)
Adds a test-service configuration action and returns this builder.
public EasyTestHostBuilder<TEntryPoint> ConfigureServices(Action<IServiceCollection> configure)
Parameters
configureAction<IServiceCollection>The callback invoked for each host after XBullet registers test authentication. It receives the host-owned service collection and may add, replace, or remove registrations. Registered callbacks run sequentially in registration order, but can run concurrently when callers construct derived factories in parallel.
Returns
- EasyTestHostBuilder<TEntryPoint>
This builder so additional host behavior can be configured.
UseSetting(string, string)
Adds or replaces one early host setting.
public EasyTestHostBuilder<TEntryPoint> UseSetting(string key, string value)
Parameters
keystringThe non-empty host-setting key to add or replace.
valuestringThe setting value. Empty strings are accepted; null is not.
Returns
- EasyTestHostBuilder<TEntryPoint>
This builder so additional host behavior can be configured.