From 4984dd2cddfac85854e98c63eadd51e31b16f2e8 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 13 Apr 2018 16:51:25 -0700 Subject: [PATCH] Revert "[Fixes #7587] No easy way to change ASPNETCORE_ENVIRONMENT" This reverts commit 22510e1377f3bdd9b8d1541feebfcb59ab620661. --- .../WebApplicationFactory.cs | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs b/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs index f1edf8fc04..910db78d92 100644 --- a/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs @@ -243,22 +243,13 @@ namespace Microsoft.AspNetCore.Mvc.Testing /// array as arguments. /// /// A instance. - protected virtual IWebHostBuilder CreateWebHostBuilder() - { - var builder = WebHostBuilderFactory.CreateFromTypesAssemblyEntryPoint(Array.Empty()); - if (builder == null) - { - throw new InvalidOperationException(Resources.FormatMissingCreateWebHostBuilderMethod( - nameof(IWebHostBuilder), - typeof(TEntryPoint).Assembly.EntryPoint.DeclaringType.FullName, - typeof(WebApplicationFactory).Name, - nameof(CreateWebHostBuilder))); - } - else - { - return builder.UseEnvironment("Development"); - } - } + protected virtual IWebHostBuilder CreateWebHostBuilder() => + WebHostBuilderFactory.CreateFromTypesAssemblyEntryPoint(Array.Empty()) ?? + throw new InvalidOperationException(Resources.FormatMissingCreateWebHostBuilderMethod( + nameof(IWebHostBuilder), + typeof(TEntryPoint).Assembly.EntryPoint.DeclaringType.FullName, + typeof(WebApplicationFactory).Name, + nameof(CreateWebHostBuilder))); /// /// Creates the with the bootstrapped application in .