diff --git a/.travis.yml b/.travis.yml index 174054f..c4c74c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,11 @@ language: csharp -mono: latest -dotnet: 1.0.4 +mono: none +dotnet: 2.1.300 dist: trusty - solution: src/GitTools.Testing.sln sudo: false -install: - - nuget install xunit.runner.console -Version 2.1.0 -OutputDirectory ./src/packages + script: - - dotnet restore src/GitTools.Testing.sln - - msbuild ./src/GitTools.Testing.sln /property:Configuration=Debug - - dotnet test ./src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj --configuration Debug --no-build --framework netcoreapp1.0 -# Disable testing against .NET 4.5.2 through Mono because it tries to resolve -# the Windows libgit binary instead of the linux one. -# - mono --debug --runtime=v4.0.30319 ./src/packages/xunit.runner.console.2.1.0/tools/xunit.console.exe ./src/GitTools.Testing.Tests/bin/Debug/net452/GitTools.Testing.Tests.dll \ No newline at end of file + - dotnet build ./src/GitTools.Testing.sln --configuration Debug + - cd ./src/GitTools.Testing.Tests + - dotnet xunit -configuration Debug -nobuild --fx-version 2.1.0 diff --git a/appveyor.yml b/appveyor.yml index c913c48..bb9e124 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,8 @@ environment: install: - choco install gitversion.portable -pre -y -image: Visual Studio 2017 Preview +image: Visual Studio 2017 + configuration: - Release @@ -25,7 +26,7 @@ after_build: test: off test_script: - cmd: cd src\GitTools.Testing.Tests - - cmd: dotnet test --configuration Release --no-build + - cmd: dotnet xunit -configuration Release -nobuild --fx-version 2.1.0 deploy: provider: NuGet diff --git a/src/GitTools.Testing.Tests/Example.cs b/src/GitTools.Testing.Tests/Example.cs index f69213e..b6ec58a 100644 --- a/src/GitTools.Testing.Tests/Example.cs +++ b/src/GitTools.Testing.Tests/Example.cs @@ -1,112 +1,22 @@ using Xunit; -using Xunit.Abstractions; namespace GitTools.Testing.Tests { - using System; -#if NET452 - using System.Runtime.Remoting.Messaging; -#endif - using JetBrains.Annotations; - using Logging; - public class Example { - private readonly ITestOutputHelper _outputHelper; - public Example(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; } - [Fact] public void TheReadmeSample() { -#if NET452 - using (LogHelper.Capture(_outputHelper, LogProvider.SetCurrentLogProvider)) - { -#endif - using (var fixture = new EmptyRepositoryFixture()) - { - fixture.MakeACommit(); - fixture.MakeACommit(); - fixture.MakeATaggedCommit("1.0.0"); - fixture.BranchTo("develop"); - fixture.MakeACommit(); - fixture.Checkout("master"); - fixture.MergeNoFF("develop"); - } -#if NET452 - } -#endif - } - } - -#if NET452 - public static class LogHelper - { - private static readonly XUnitProvider Provider; - - static LogHelper() - { - Provider = new XUnitProvider(); - } - - public static IDisposable Capture(ITestOutputHelper outputHelper, Action setProvider) - { - // TODO Only do this once - setProvider(Provider); - - CallContext.SetData("CurrentOutputHelper", outputHelper); - - return new DelegateDisposable(() => - { - CallContext.SetData("CurrentOutputHelper", null); - }); - } - - class DelegateDisposable : IDisposable - { - private readonly Action _action; - - public DelegateDisposable(Action action) + using (var fixture = new EmptyRepositoryFixture()) { - _action = action; + fixture.MakeACommit(); + fixture.MakeACommit(); + fixture.MakeATaggedCommit("1.0.0"); + fixture.BranchTo("develop"); + fixture.MakeACommit(); + fixture.Checkout("master"); + fixture.MergeNoFF("develop"); } - - public void Dispose() - { - _action(); - } - } - } - - public class XUnitProvider : ILogProvider - { - public Logger GetLogger(string name) - { - return XUnitLogger; - } - - private bool XUnitLogger(LogLevel logLevel, [CanBeNull] Func messageFunc, [CanBeNull] Exception exception, params object[] formatParameters) - { - if (messageFunc == null) return true; - var currentHelper = (ITestOutputHelper)CallContext.GetData("CurrentOutputHelper"); - if (currentHelper == null) - return false; - - currentHelper.WriteLine("[{0}] {1}", logLevel, messageFunc()); - if (exception != null) - currentHelper.WriteLine("Exception:{0}{1}", Environment.NewLine, exception.ToString()); - - return true; - } - - public IDisposable OpenNestedContext(string message) - { - throw new NotImplementedException(); - } - - public IDisposable OpenMappedContext(string key, string value) - { - throw new NotImplementedException(); } } -#endif } \ No newline at end of file diff --git a/src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj b/src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj index 7cca81e..ef28ddc 100644 --- a/src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj +++ b/src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj @@ -4,7 +4,7 @@ Debug Any CPU Library - net452;netcoreapp1.0 + netcoreapp2.0 bin\$(Configuration)\ true false @@ -33,18 +33,13 @@ TRACE - + - - + + + - - - - - - diff --git a/src/GitTools.Testing.sln b/src/GitTools.Testing.sln index 036c4de..22b414b 100644 --- a/src/GitTools.Testing.sln +++ b/src/GitTools.Testing.sln @@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".configs", ".configs", "{EB ProjectSection(SolutionItems) = preProject ..\.travis.yml = ..\.travis.yml ..\appveyor.yml = ..\appveyor.yml - ..\GitVersionConfig.yaml = ..\GitVersionConfig.yaml + ..\GitVersion.yml = ..\GitVersion.yml ..\README.md = ..\README.md EndProjectSection EndProject @@ -33,4 +33,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B5BD4730-E58A-46CD-A37E-47884080BE88} + EndGlobalSection EndGlobal diff --git a/src/GitTools.Testing/GitTools.Testing.csproj b/src/GitTools.Testing/GitTools.Testing.csproj index 37d8e74..23ecb70 100644 --- a/src/GitTools.Testing/GitTools.Testing.csproj +++ b/src/GitTools.Testing/GitTools.Testing.csproj @@ -1,11 +1,9 @@  - net452;netstandard1.3 + netstandard2.0 true false bin\$(Configuration)\ - - $(DefineConstants);LIBLOG_PORTABLE @@ -16,9 +14,7 @@ - - - + - + \ No newline at end of file