From 8a6ec9d22ffa13aa421d7548021205e370426f28 Mon Sep 17 00:00:00 2001 From: SilverFox Date: Mon, 12 Mar 2018 07:57:03 +0800 Subject: [PATCH] Test --- build.cake | 4 ++-- .../Logging/InternalLoggerFactoryTest.cs | 20 +++++++++++++++++-- .../Utilities/HashedWheelTimerTest.cs | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/build.cake b/build.cake index fdf8059e9..bc20d2aaf 100644 --- a/build.cake +++ b/build.cake @@ -79,7 +79,7 @@ Task("Test") .IsDependentOn("Compile") .Does(() => { - var projects = GetFiles("./test/**/*.csproj") + var projects = GetFiles("./test/DotNetty.Common.Tests/*.csproj") - GetFiles("./test/**/*.Microbench.csproj") - GetFiles("./test/**/*.Performance.csproj"); @@ -88,7 +88,7 @@ Task("Test") DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings { Configuration = configuration//, - //Verbose = false + Verbose = true }); // if (IsRunningOnWindows()) diff --git a/test/DotNetty.Common.Tests/Internal/Logging/InternalLoggerFactoryTest.cs b/test/DotNetty.Common.Tests/Internal/Logging/InternalLoggerFactoryTest.cs index 67234facb..0ca91f585 100644 --- a/test/DotNetty.Common.Tests/Internal/Logging/InternalLoggerFactoryTest.cs +++ b/test/DotNetty.Common.Tests/Internal/Logging/InternalLoggerFactoryTest.cs @@ -4,15 +4,23 @@ namespace DotNetty.Common.Tests.Internal.Logging { using System; + using System.Runtime.CompilerServices; using DotNetty.Common.Internal.Logging; using DotNetty.Tests.Common; using Microsoft.Extensions.Logging; using Moq; using Xunit; + using Xunit.Abstractions; [CollectionDefinition(nameof(InternalLoggerFactoryTest), DisableParallelization = true)] public class InternalLoggerFactoryTest { + protected readonly ITestOutputHelper Output; + + protected InternalLoggerFactoryTest(ITestOutputHelper output) + { + this.Output = output; + } // todo: CodeContracts on CI //[Fact] //public void ShouldNotAllowNullDefaultFactory() @@ -34,6 +42,7 @@ public void ShouldGetInstance() [Fact] public void TestMockReturned() { + Output.WriteLine("TestMockReturned, Pre:" + RuntimeHelpers.GetHashCode(InternalLoggerFactory.DefaultFactory)); Mock mock; using (SetupMockLogger(out mock)) { @@ -43,20 +52,27 @@ public void TestMockReturned() Assert.True(logger.TraceEnabled); mock.Verify(x => x.IsEnabled(LogLevel.Trace), Times.Once); + Output.WriteLine("TestMockReturned, Finish:" + RuntimeHelpers.GetHashCode(InternalLoggerFactory.DefaultFactory)); } + Output.WriteLine("TestMockReturned, Post:" + RuntimeHelpers.GetHashCode(InternalLoggerFactory.DefaultFactory)); } - static IDisposable SetupMockLogger(out Mock loggerMock) + IDisposable SetupMockLogger(out Mock loggerMock) { ILoggerFactory oldLoggerFactory = InternalLoggerFactory.DefaultFactory; + Output.WriteLine($"SetupMockLogger,oldLoggerFactory={RuntimeHelpers.GetHashCode(oldLoggerFactory)}"); var loggerFactory = new LoggerFactory(); + Output.WriteLine($"SetupMockLogger,loggerFactory={RuntimeHelpers.GetHashCode(loggerFactory)}"); var factoryMock = new Mock(MockBehavior.Strict); ILoggerProvider mockFactory = factoryMock.Object; loggerMock = new Mock(MockBehavior.Strict); loggerFactory.AddProvider(mockFactory); factoryMock.Setup(x => x.CreateLogger("mock")).Returns(loggerMock.Object); InternalLoggerFactory.DefaultFactory = loggerFactory; - return new Disposable(() => InternalLoggerFactory.DefaultFactory = oldLoggerFactory); + return new Disposable(() => { + InternalLoggerFactory.DefaultFactory = oldLoggerFactory; + Output.WriteLine($"SetupMockLogger,Dispose to={RuntimeHelpers.GetHashCode(oldLoggerFactory)}"); + }); } } } \ No newline at end of file diff --git a/test/DotNetty.Common.Tests/Utilities/HashedWheelTimerTest.cs b/test/DotNetty.Common.Tests/Utilities/HashedWheelTimerTest.cs index 440793dc0..0021bf28d 100644 --- a/test/DotNetty.Common.Tests/Utilities/HashedWheelTimerTest.cs +++ b/test/DotNetty.Common.Tests/Utilities/HashedWheelTimerTest.cs @@ -54,6 +54,7 @@ public void TestScheduleTimeoutShouldRunAfterDelay() [Fact] // (timeout = 3000) public void TestStopTimer() { + Output.WriteLine($"{System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(DotNetty.Common.Internal.Logging.InternalLoggerFactory.DefaultFactory)}"); var latch = new CountdownEvent(3); ITimer timerProcessed = new HashedWheelTimer(); for (int i = 0; i < 3; i++)