diff --git a/src/ServiceComposer.AspNetCore.Testing.Tests/ApiApprovals.Approve_API.verified.txt b/src/ServiceComposer.AspNetCore.Testing.Tests/ApiApprovals.Approve_API.verified.txt index f7ad6cf..ac1395a 100644 --- a/src/ServiceComposer.AspNetCore.Testing.Tests/ApiApprovals.Approve_API.verified.txt +++ b/src/ServiceComposer.AspNetCore.Testing.Tests/ApiApprovals.Approve_API.verified.txt @@ -14,6 +14,7 @@ public SelfContainedWebApplicationFactoryWithWebHost(System.Action configureServices, System.Action configure) { } public SelfContainedWebApplicationFactoryWithWebHost(System.Action configureServices, System.Action configure) { } public System.Action BuilderCustomization { get; set; } + public string Environment { get; set; } protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { } protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { } } @@ -22,6 +23,7 @@ { public WebApplicationFactoryWithWebHost() { } public System.Action BuilderCustomization { get; set; } + public string Environment { get; set; } protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { } protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { } } diff --git a/src/ServiceComposer.AspNetCore.Testing/SelfContainedWebApplicationFactoryWithWebHost.cs b/src/ServiceComposer.AspNetCore.Testing/SelfContainedWebApplicationFactoryWithWebHost.cs index 6b33753..db584a9 100644 --- a/src/ServiceComposer.AspNetCore.Testing/SelfContainedWebApplicationFactoryWithWebHost.cs +++ b/src/ServiceComposer.AspNetCore.Testing/SelfContainedWebApplicationFactoryWithWebHost.cs @@ -24,6 +24,7 @@ public class SelfContainedWebApplicationFactoryWithWebHost : readonly Action _configureServicesWithWebHostBuilderContext; readonly Action _configureWithWebHostBuilderContext; + public string Environment { get; set; } = Environments.Development; public Action BuilderCustomization { get; set; } public SelfContainedWebApplicationFactoryWithWebHost(Action configureServices, Action configure) @@ -41,6 +42,7 @@ public SelfContainedWebApplicationFactoryWithWebHost(Action()) + .UseEnvironment(Environment) .ConfigureWebHostDefaults(webBuilder => { if (_configureServices != null) diff --git a/src/ServiceComposer.AspNetCore.Testing/WebApplicationFactoryWithWebHost.cs b/src/ServiceComposer.AspNetCore.Testing/WebApplicationFactoryWithWebHost.cs index da39ed8..3cbc9a8 100644 --- a/src/ServiceComposer.AspNetCore.Testing/WebApplicationFactoryWithWebHost.cs +++ b/src/ServiceComposer.AspNetCore.Testing/WebApplicationFactoryWithWebHost.cs @@ -9,11 +9,13 @@ public class WebApplicationFactoryWithWebHost : WebApplicationFactory where TStartup : class { + public string Environment { get; set; } = Environments.Development; public Action BuilderCustomization { get; set; } protected override IHostBuilder CreateHostBuilder() { return Host.CreateDefaultBuilder(Array.Empty()) + .UseEnvironment(Environment) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup();