Table of Contents

Class AppConfiguratorExtensions

Namespace
FEFF.TestFixtures.AspNetCore
Assembly
FEFF.TestFixtures.AspNetCore.dll

Extension methods for IAppConfigurator to simplify test application configuration.

public static class AppConfiguratorExtensions
Inheritance
AppConfiguratorExtensions
Inherited Members

Methods

ConfigureServices(IAppConfigurator, Action<WebHostBuilderContext, IServiceCollection>)

Adds a delegate for configuring the IServiceCollection on the web host with access to the WebHostBuilderContext.

public static void ConfigureServices(this IAppConfigurator builder, Action<WebHostBuilderContext, IServiceCollection> configureServices)

Parameters

builder IAppConfigurator

The app configurator.

configureServices Action<WebHostBuilderContext, IServiceCollection>

A delegate for configuring services.

ConfigureServices(IAppConfigurator, Action<IServiceCollection>)

Adds a delegate for configuring the IServiceCollection on the web host.

public static void ConfigureServices(this IAppConfigurator builder, Action<IServiceCollection> configureServices)

Parameters

builder IAppConfigurator

The app configurator.

configureServices Action<IServiceCollection>

A delegate for configuring services.

UseAspEnvironment(IAppConfigurator, AspEnvironment)

Sets the ASP.NET Core environment for the web host.

public static void UseAspEnvironment(this IAppConfigurator builder, AspEnvironment env)

Parameters

builder IAppConfigurator

The app configurator.

env AspEnvironment

The environment to use.

UseDatabaseNamePostfix(IAppConfigurator, string, IReadOnlyCollection<string>)

Appends a suffix to the database name in the specified connection strings. Useful for creating isolated databases per test.

public static void UseDatabaseNamePostfix(this IAppConfigurator builder, string suffix, IReadOnlyCollection<string> connectionStringNames)

Parameters

builder IAppConfigurator

The app configurator.

suffix string

The suffix to append to the database name.

connectionStringNames IReadOnlyCollection<string>

The names of the connection strings to modify.

Exceptions

ArgumentException

Thrown when connectionStringNames is null or empty.

UseLoggerProvider(IAppConfigurator, ILoggerProvider)

Adds a custom ILoggerProvider to the application's logging pipeline.

public static void UseLoggerProvider(this IAppConfigurator builder, ILoggerProvider loggerProvider)

Parameters

builder IAppConfigurator

The app configurator.

loggerProvider ILoggerProvider

The logger provider to add.

UseRandom(IAppConfigurator, Random)

Replaces the application's Random with a custom instance.

public static void UseRandom(this IAppConfigurator builder, Random random)

Parameters

builder IAppConfigurator

The app configurator.

random Random

The Random instance to use.

UseSetting(IAppConfigurator, string, string?)

Sets a configuration setting on the web host.

public static void UseSetting(this IAppConfigurator builder, string key, string? value)

Parameters

builder IAppConfigurator

The app configurator.

key string

The configuration key.

value string

The configuration value.

UseTimeProvider(IAppConfigurator, TimeProvider)

Replaces the application's TimeProvider with a custom instance.

public static void UseTimeProvider(this IAppConfigurator builder, TimeProvider timeProvider)

Parameters

builder IAppConfigurator

The app configurator.

timeProvider TimeProvider

The TimeProvider instance to use.