From 5d34e7550e767b0b1aa88683e7abe32eac845fd3 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Tue, 24 Oct 2017 12:29:16 +1300 Subject: [PATCH] Fix Path operations on non-Windows platforms --- Source/AsyncGenerator.Tests/BaseFixture.cs | 14 ++++---------- .../ExternalProjects/NHibernate/Fixture.cs | 6 ++++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/AsyncGenerator.Tests/BaseFixture.cs b/Source/AsyncGenerator.Tests/BaseFixture.cs index 191f7c92..2e04128d 100644 --- a/Source/AsyncGenerator.Tests/BaseFixture.cs +++ b/Source/AsyncGenerator.Tests/BaseFixture.cs @@ -38,19 +38,13 @@ protected BaseFixture(string folderPath = null) public string GetBaseDirectory() { - // BaseDirectory ends with a backslash when running with Visual Studio (Test Explorer), but when running with - // Reshaper (Unit Test Session) there is no backslash at the end - var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - if (!baseDirectory.EndsWith(@"\")) - { - baseDirectory += @"\"; - } - return baseDirectory; + return AppDomain.CurrentDomain.BaseDirectory; } public AsyncCodeConfiguration Configure(Action action = null) { - var filePath = Path.GetFullPath(GetBaseDirectory() + @"..\..\AsyncGenerator.Tests.csproj"); + var filePath = Path.GetFullPath(Path.Combine(GetBaseDirectory(), "..", "..", "AsyncGenerator.Tests.csproj")); + return AsyncCodeConfiguration.Create() .ConfigureProject(filePath, p => { @@ -71,7 +65,7 @@ public AsyncCodeConfiguration Configure(Action acti public AsyncCodeConfiguration Configure(string fileName, Action action = null) { - var slnFilePath = Path.GetFullPath(GetBaseDirectory() + @"..\..\..\AsyncGenerator.sln"); + var slnFilePath = Path.GetFullPath(Path.Combine(GetBaseDirectory(), "..", "..", "..", "AsyncGenerator.sln")); return AsyncCodeConfiguration.Create() .ConfigureSolution(slnFilePath, c => c .ConfigureProject("AsyncGenerator.Tests", p => diff --git a/Source/AsyncGenerator.Tests/ExternalProjects/NHibernate/Fixture.cs b/Source/AsyncGenerator.Tests/ExternalProjects/NHibernate/Fixture.cs index b8ed29f5..5b8cc538 100644 --- a/Source/AsyncGenerator.Tests/ExternalProjects/NHibernate/Fixture.cs +++ b/Source/AsyncGenerator.Tests/ExternalProjects/NHibernate/Fixture.cs @@ -65,7 +65,8 @@ public void TestYamlProjectConfigurationAfterTransformation() [Test] public void TestYamlAfterTransformation() { - var configPath = Path.GetFullPath(GetBaseDirectory() + @"..\..\ExternalProjects\NHibernate\Source\src\AsyncGenerator.yml"); + var configPath = Path.GetFullPath(Path.Combine(GetBaseDirectory(), "..", "..", "ExternalProjects", "NHibernate","Source","src","AsyncGenerator.yml")); + var config = AsyncCodeConfiguration.Create() .ConfigureFromFile(configPath); var generator = new AsyncCodeGenerator(); @@ -76,7 +77,8 @@ public void TestYamlAfterTransformation() [Test] public void TestAfterTransformation() { - var slnFilePath = Path.GetFullPath(GetBaseDirectory() + @"..\..\ExternalProjects\NHibernate\Source\src\NHibernate.sln"); + var slnFilePath = Path.GetFullPath(Path.Combine(GetBaseDirectory(), "..", "..", "ExternalProjects", "NHibernate", "Source", "src", "NHibernate.sln")); + var config = AsyncCodeConfiguration.Create() .ConfigureSolution(slnFilePath, s => s .ConcurrentRun()