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
builderIAppConfiguratorThe app configurator.
configureServicesAction<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
builderIAppConfiguratorThe app configurator.
configureServicesAction<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
builderIAppConfiguratorThe app configurator.
envAspEnvironmentThe 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
builderIAppConfiguratorThe app configurator.
suffixstringThe suffix to append to the database name.
connectionStringNamesIReadOnlyCollection<string>The names of the connection strings to modify.
Exceptions
- ArgumentException
Thrown when
connectionStringNamesis 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
builderIAppConfiguratorThe app configurator.
loggerProviderILoggerProviderThe 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
builderIAppConfiguratorThe app configurator.
randomRandomThe 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
builderIAppConfiguratorThe app configurator.
keystringThe configuration key.
valuestringThe configuration value.
UseTimeProvider(IAppConfigurator, TimeProvider)
Replaces the application's TimeProvider with a custom instance.
public static void UseTimeProvider(this IAppConfigurator builder, TimeProvider timeProvider)
Parameters
builderIAppConfiguratorThe app configurator.
timeProviderTimeProviderThe TimeProvider instance to use.