[Fixes #7587] Default to Development environment in tests
This commit is contained in:
parent
e0e96ce53b
commit
e0b4c13895
|
|
@ -243,13 +243,22 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
||||||
/// array as arguments.
|
/// array as arguments.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>A <see cref="IWebHostBuilder"/> instance.</returns>
|
/// <returns>A <see cref="IWebHostBuilder"/> instance.</returns>
|
||||||
protected virtual IWebHostBuilder CreateWebHostBuilder() =>
|
protected virtual IWebHostBuilder CreateWebHostBuilder()
|
||||||
WebHostBuilderFactory.CreateFromTypesAssemblyEntryPoint<TEntryPoint>(Array.Empty<string>()) ??
|
{
|
||||||
throw new InvalidOperationException(Resources.FormatMissingCreateWebHostBuilderMethod(
|
var builder = WebHostBuilderFactory.CreateFromTypesAssemblyEntryPoint<TEntryPoint>(Array.Empty<string>());
|
||||||
nameof(IWebHostBuilder),
|
if (builder == null)
|
||||||
typeof(TEntryPoint).Assembly.EntryPoint.DeclaringType.FullName,
|
{
|
||||||
typeof(WebApplicationFactory<TEntryPoint>).Name,
|
throw new InvalidOperationException(Resources.FormatMissingCreateWebHostBuilderMethod(
|
||||||
nameof(CreateWebHostBuilder)));
|
nameof(IWebHostBuilder),
|
||||||
|
typeof(TEntryPoint).Assembly.EntryPoint.DeclaringType.FullName,
|
||||||
|
typeof(WebApplicationFactory<TEntryPoint>).Name,
|
||||||
|
nameof(CreateWebHostBuilder)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return builder.UseEnvironment("Development");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the <see cref="TestServer"/> with the bootstrapped application in <paramref name="builder"/>.
|
/// Creates the <see cref="TestServer"/> with the bootstrapped application in <paramref name="builder"/>.
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.UseRequestCulture<TStartup>("en-GB", "en-US")
|
.UseRequestCulture<TStartup>("en-GB", "en-US")
|
||||||
|
.UseEnvironment("Production")
|
||||||
.ConfigureServices(
|
.ConfigureServices(
|
||||||
services => services.Configure<MvcCompatibilityOptions>(
|
services => services.Configure<MvcCompatibilityOptions>(
|
||||||
options => options.CompatibilityVersion = CompatibilityVersion.Version_2_1));
|
options => options.CompatibilityVersion = CompatibilityVersion.Version_2_1));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue