Make webhost setup less confusing.
This commit is contained in:
@@ -142,32 +142,26 @@ namespace Umbraco.Cms.Tests.Integration.TestServerTest
|
||||
|
||||
Configuration = configBuilder.Build();
|
||||
})
|
||||
/* It is important that ConfigureWebHost is called before ConfigureServices, this is consistent with the host setup
|
||||
* found in Program.cs and avoids nasty surprises.
|
||||
*
|
||||
* e.g. the registration for RefreshingRazorViewEngine requires that IWebHostEnvironment is registered
|
||||
* at the point in time that the service collection is snapshotted.
|
||||
*/
|
||||
.ConfigureWebHost(builder =>
|
||||
{
|
||||
// need to configure the IWebHostEnvironment too
|
||||
builder.ConfigureServices((c, s) => c.HostingEnvironment = TestHelper.GetWebHostEnvironment());
|
||||
builder.ConfigureServices((context, services) =>
|
||||
{
|
||||
context.HostingEnvironment = TestHelper.GetWebHostEnvironment();
|
||||
|
||||
ConfigureServices(services);
|
||||
ConfigureTestSpecificServices(services);
|
||||
|
||||
if (!TestOptions.Boot)
|
||||
{
|
||||
// If boot is false, we don't want the CoreRuntime hosted service to start
|
||||
// So we replace it with a Mock
|
||||
services.AddUnique(Mock.Of<IRuntime>());
|
||||
}
|
||||
});
|
||||
|
||||
// call startup
|
||||
builder.Configure(Configure);
|
||||
})
|
||||
.ConfigureServices((_, services) =>
|
||||
{
|
||||
ConfigureServices(services);
|
||||
ConfigureTestSpecificServices(services);
|
||||
|
||||
if (!TestOptions.Boot)
|
||||
{
|
||||
// If boot is false, we don't want the CoreRuntime hosted service to start
|
||||
// So we replace it with a Mock
|
||||
services.AddUnique(Mock.Of<IRuntime>());
|
||||
}
|
||||
})
|
||||
.UseDefaultServiceProvider(cfg =>
|
||||
{
|
||||
// These default to true *if* WebHostEnvironment.EnvironmentName == Development
|
||||
|
||||
Reference in New Issue
Block a user