Add addtional test and some comments

This commit is contained in:
John Luo 2016-03-25 17:11:21 -07:00
parent 4b16e83a1f
commit a406bfd86f
2 changed files with 22 additions and 2 deletions

View File

@ -221,8 +221,8 @@ namespace Microsoft.AspNetCore.Hosting
configureLogging(_loggerFactory);
}
services.AddSingleton(_loggerFactory);
services.AddLogging();
services.AddSingleton(_loggerFactory); //The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one.
services.AddLogging(); //This is required to add ILogger of T.
services.AddTransient<IStartupLoader, StartupLoader>();

View File

@ -169,6 +169,26 @@ namespace Microsoft.AspNetCore.Hosting
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]
public void DefaultHostingConfigurationDoesNotCaptureStartupErrors()
{