Skip to content

Commit

Permalink
The same as 846d2e9
Browse files Browse the repository at this point in the history
  • Loading branch information
yyjdelete committed Mar 12, 2018
1 parent 671e175 commit f64d2b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Task("Test")
.IsDependentOn("Compile")
.Does(() =>
{
var projects = GetFiles("./test/DotNetty.Common.Tests/*.csproj")
var projects = GetFiles("./test/**/*.csproj")
- GetFiles("./test/**/*.Microbench.csproj")
- GetFiles("./test/**/*.Performance.csproj");
Expand All @@ -88,7 +88,7 @@ Task("Test")
DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings
{
Configuration = configuration//,
//Verbosity = DotNetCoreVerbosity.Normal
//Verbose = false
});
// if (IsRunningOnWindows())
Expand Down
26 changes: 13 additions & 13 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
}

#if($FoundDotNetCliVersion -ne $DotNetVersion) {
# $InstallPath = Join-Path $PSScriptRoot ".dotnet"
# if (!(Test-Path $InstallPath)) {
# mkdir -Force $InstallPath | Out-Null;
# }
# (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
# & $InstallPath\dotnet-install.ps1 -Channel preview -Version $DotNetVersion -InstallDir $InstallPath;

# $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# $env:DOTNET_CLI_TELEMETRY_OPTOUT=1

# & dotnet --info
#}
if($FoundDotNetCliVersion -ne $DotNetVersion) {
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
mkdir -Force $InstallPath | Out-Null;
}
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel preview -Version $DotNetVersion -InstallDir $InstallPath;

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1

& dotnet --info
}

###########################################################################
# INSTALL CAKE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
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;
public InternalLoggerFactoryTest(ITestOutputHelper output)
{
this.Output = output;
}*/
// todo: CodeContracts on CI
//[Fact]
//public void ShouldNotAllowNullDefaultFactory()
Expand All @@ -42,7 +34,6 @@ public void ShouldGetInstance()
[Fact]
public void TestMockReturned()
{
//Output.WriteLine("TestMockReturned, Pre:" + RuntimeHelpers.GetHashCode(InternalLoggerFactory.DefaultFactory));
Mock<ILogger> mock;
using (SetupMockLogger(out mock))
{
Expand All @@ -52,28 +43,20 @@ 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));
//Assert.True(false, "To See The Log");
}

static IDisposable SetupMockLogger(out Mock<ILogger> 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<ILoggerProvider>(MockBehavior.Strict);
ILoggerProvider mockFactory = factoryMock.Object;
loggerMock = new Mock<ILogger>(MockBehavior.Strict);
loggerFactory.AddProvider(mockFactory);
factoryMock.Setup(x => x.CreateLogger("mock")).Returns(loggerMock.Object);
InternalLoggerFactory.DefaultFactory = loggerFactory;
return new Disposable(() => {
InternalLoggerFactory.DefaultFactory = oldLoggerFactory;
//Output.WriteLine($"SetupMockLogger,Dispose to={RuntimeHelpers.GetHashCode(oldLoggerFactory)}");
});
return new Disposable(() => InternalLoggerFactory.DefaultFactory = oldLoggerFactory);
}
}
}
2 changes: 0 additions & 2 deletions test/DotNetty.Common.Tests/Utilities/HashedWheelTimerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ 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++)
Expand All @@ -78,7 +77,6 @@ public void TestStopTimer()
}
Thread.Sleep(1000); // sleep for a second
Assert.NotEqual(0, timerUnprocessed.StopAsync().Result.Count); // Number of unprocessed timeouts should be greater than 0
//Assert.True(false, "To See The Log");
}

[Fact] // (timeout = 3000)
Expand Down

0 comments on commit f64d2b3

Please sign in to comment.