Skip to content

Commit d87d916

Browse files
Default the environment to Development (#217)
1 parent 1e226d5 commit d87d916

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/ServiceComposer.AspNetCore.Testing.Tests/ApiApprovals.Approve_API.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public SelfContainedWebApplicationFactoryWithWebHost(System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> configureServices, System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> configure) { }
1515
public SelfContainedWebApplicationFactoryWithWebHost(System.Action<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection> configureServices, System.Action<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, Microsoft.AspNetCore.Builder.IApplicationBuilder> configure) { }
1616
public System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder> BuilderCustomization { get; set; }
17+
public string Environment { get; set; }
1718
protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { }
1819
protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { }
1920
}
@@ -22,6 +23,7 @@
2223
{
2324
public WebApplicationFactoryWithWebHost() { }
2425
public System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder> BuilderCustomization { get; set; }
26+
public string Environment { get; set; }
2527
protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { }
2628
protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { }
2729
}

src/ServiceComposer.AspNetCore.Testing/SelfContainedWebApplicationFactoryWithWebHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class SelfContainedWebApplicationFactoryWithWebHost<TEntryPoint> :
2424
readonly Action<WebHostBuilderContext, IServiceCollection> _configureServicesWithWebHostBuilderContext;
2525
readonly Action<WebHostBuilderContext, IApplicationBuilder> _configureWithWebHostBuilderContext;
2626

27+
public string Environment { get; set; } = Environments.Development;
2728
public Action<IWebHostBuilder> BuilderCustomization { get; set; }
2829

2930
public SelfContainedWebApplicationFactoryWithWebHost(Action<IServiceCollection> configureServices, Action<IApplicationBuilder> configure)
@@ -41,6 +42,7 @@ public SelfContainedWebApplicationFactoryWithWebHost(Action<WebHostBuilderContex
4142
protected override IHostBuilder CreateHostBuilder()
4243
{
4344
return Host.CreateDefaultBuilder(Array.Empty<string>())
45+
.UseEnvironment(Environment)
4446
.ConfigureWebHostDefaults(webBuilder =>
4547
{
4648
if (_configureServices != null)

src/ServiceComposer.AspNetCore.Testing/WebApplicationFactoryWithWebHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ public class WebApplicationFactoryWithWebHost<TStartup> :
99
WebApplicationFactory<TStartup>
1010
where TStartup : class
1111
{
12+
public string Environment { get; set; } = Environments.Development;
1213
public Action<IWebHostBuilder> BuilderCustomization { get; set; }
1314

1415
protected override IHostBuilder CreateHostBuilder()
1516
{
1617
return Host.CreateDefaultBuilder(Array.Empty<string>())
18+
.UseEnvironment(Environment)
1719
.ConfigureWebHostDefaults(webBuilder =>
1820
{
1921
webBuilder.UseStartup<TStartup>();

0 commit comments

Comments
 (0)