Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Created January 28, 2022 00:41
Show Gist options
  • Save tonysneed/4e0f736ce28b7b3fe7ff93fb53fcce4f to your computer and use it in GitHub Desktop.
Save tonysneed/4e0f736ce28b7b3fe7ff93fb53fcce4f to your computer and use it in GitHub Desktop.
private WebApplicationFactory<Program> GetWebApplicationFactory() =>
new WebApplicationFactory<Program>()
.WithWebHostBuilder(builder =>
{
IConfigurationSection? configSection = null;
builder.ConfigureAppConfiguration((context, config) =>
{
config.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), AppSettingsFile));
configSection = context.Configuration.GetSection(nameof(WeatherDatabaseSettings));
});
builder.ConfigureTestServices(services =>
services.Configure<WeatherDatabaseSettings>(configSection));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment