Add addtional test and some comments
This commit is contained in:
parent
4b16e83a1f
commit
a406bfd86f
|
|
@ -221,8 +221,8 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
configureLogging(_loggerFactory);
|
configureLogging(_loggerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
services.AddSingleton(_loggerFactory);
|
services.AddSingleton(_loggerFactory); //The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one.
|
||||||
services.AddLogging();
|
services.AddLogging(); //This is required to add ILogger of T.
|
||||||
|
|
||||||
services.AddTransient<IStartupLoader, StartupLoader>();
|
services.AddTransient<IStartupLoader, StartupLoader>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,26 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
Assert.Same(loggerFactory, host.Services.GetService<ILoggerFactory>());
|
Assert.Same(loggerFactory, host.Services.GetService<ILoggerFactory>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void MultipleConfigureLoggingInvokedInOrder()
|
||||||
|
{
|
||||||
|
var callCount = 0; //Verify ordering
|
||||||
|
var hostBuilder = new WebHostBuilder()
|
||||||
|
.ConfigureLogging(loggerFactory =>
|
||||||
|
{
|
||||||
|
Assert.Equal(0, callCount++);
|
||||||
|
})
|
||||||
|
.ConfigureLogging(loggerFactory =>
|
||||||
|
{
|
||||||
|
Assert.Equal(1, callCount++);
|
||||||
|
})
|
||||||
|
.UseServer(new TestServer())
|
||||||
|
.UseStartup<StartupNoServices>();
|
||||||
|
|
||||||
|
var host = (WebHost)hostBuilder.Build();
|
||||||
|
Assert.Equal(2, callCount);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void DefaultHostingConfigurationDoesNotCaptureStartupErrors()
|
public void DefaultHostingConfigurationDoesNotCaptureStartupErrors()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue