Test for categoryName passed to ILoggerFactory.CreateLogger() in KestrelServer.ctor() (#797)

This commit is contained in:
Cesar Blum Silveira 2016-08-25 11:53:16 -07:00
parent 08d7f66108
commit b6a177ef0b
1 changed files with 10 additions and 2 deletions

View File

@ -2,14 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Reflection;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Server.KestrelTests
@ -75,6 +75,14 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
Assert.Equal(1, testLogger.CriticalErrorsLogged);
}
[Fact]
public void LoggerCategoryNameIsKestrelServerNamespace()
{
var mockLoggerFactory = new Mock<ILoggerFactory>();
new KestrelServer(Options.Create<KestrelServerOptions>(null), new LifetimeNotImplemented(), mockLoggerFactory.Object);
mockLoggerFactory.Verify(factory => factory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel"));
}
private static KestrelServer CreateServer(KestrelServerOptions options, ILogger testLogger)
{
var lifetime = new LifetimeNotImplemented();