diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs
index 29934f08c..4c984bd34 100644
--- a/LibGit2Sharp.Tests/BlobFixture.cs
+++ b/LibGit2Sharp.Tests/BlobFixture.cs
@@ -222,7 +222,7 @@ public void CanTellIfTheBlobContentLooksLikeBinary()
private static void SkipIfNotSupported(string autocrlf)
{
- InconclusiveIf(() => autocrlf == "true" && IsRunningOnUnix(), "Non-Windows does not support core.autocrlf = true");
+ InconclusiveIf(() => autocrlf == "true" && Constants.IsRunningOnUnix, "Non-Windows does not support core.autocrlf = true");
}
}
}
diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
index 904c427d7..f608ab440 100644
--- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
+++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -52,6 +52,9 @@
TestHelpers\Epoch.cs
+
+ TestHelpers\Platform.cs
+
diff --git a/LibGit2Sharp.Tests/ShadowCopyFixture.cs b/LibGit2Sharp.Tests/ShadowCopyFixture.cs
index 5f57a800c..f394e987e 100644
--- a/LibGit2Sharp.Tests/ShadowCopyFixture.cs
+++ b/LibGit2Sharp.Tests/ShadowCopyFixture.cs
@@ -57,7 +57,7 @@ public void CanProbeForNativeBinariesFromAShadowCopiedAssembly()
string cachedAssembliesPath = Path.Combine(setup.CachePath, setup.ApplicationName);
Assert.True(cachedAssemblyLocation.StartsWith(cachedAssembliesPath));
- if (!IsRunningOnUnix())
+ if (!Constants.IsRunningOnUnix)
{
// ...that this cache doesn't contain the `NativeBinaries` folder
string cachedAssemblyParentPath = Path.GetDirectoryName(cachedAssemblyLocation);
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index 0ee8a5569..017404760 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -106,14 +106,6 @@ private static bool IsFileSystemCaseSensitiveInternal()
return !isInsensitive;
}
- // Should match LibGit2Sharp.Core.NativeMethods.IsRunningOnUnix()
- protected static bool IsRunningOnUnix()
- {
- // see http://mono-project.com/FAQ%3a_Technical#Mono_Platforms
- var p = (int)Environment.OSVersion.Platform;
- return (p == 4) || (p == 6) || (p == 128);
- }
-
protected void CreateCorruptedDeadBeefHead(string repoPath)
{
const string deadbeef = "deadbeef";
diff --git a/LibGit2Sharp.Tests/TestHelpers/Constants.cs b/LibGit2Sharp.Tests/TestHelpers/Constants.cs
index 5a389136c..85f95c0fc 100644
--- a/LibGit2Sharp.Tests/TestHelpers/Constants.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/Constants.cs
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
+using System.Reflection;
+using LibGit2Sharp.Core;
namespace LibGit2Sharp.Tests.TestHelpers
{
@@ -30,6 +32,15 @@ public static class Constants
public const string PrivateRepoUrl = "";
+ public static bool IsRunningOnUnix
+ {
+ get
+ {
+ return Platform.OperatingSystem == OperatingSystemType.MacOSX ||
+ Platform.OperatingSystem == OperatingSystemType.Unix;
+ }
+ }
+
public static Credentials PrivateRepoCredentials(string url, string usernameFromUrl,
SupportedCredentialTypes types)
{
@@ -40,19 +51,15 @@ public static string BuildPath()
{
string tempPath = null;
- var unixPath = Type.GetType("Mono.Unix.UnixPath, Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
-
- if (unixPath != null)
+ if (IsRunningOnUnix)
{
// We're running on Mono/*nix. Let's unwrap the path
- tempPath = (string)unixPath.InvokeMember("GetCompleteRealPath",
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy |
- System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public,
- null, unixPath, new object[] { Path.GetTempPath() });
+ tempPath = UnwrapUnixTempPath();
}
else
{
const string LibGit2TestPath = "LibGit2TestPath";
+
// We're running on .Net/Windows
if (Environment.GetEnvironmentVariables().Contains(LibGit2TestPath))
{
@@ -72,6 +79,16 @@ public static string BuildPath()
return testWorkingDirectory;
}
+ private static string UnwrapUnixTempPath()
+ {
+ var type = Type.GetType("Mono.Unix.UnixPath, Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
+
+ return (string)type.InvokeMember("GetCompleteRealPath",
+ BindingFlags.Static | BindingFlags.FlattenHierarchy |
+ BindingFlags.InvokeMethod | BindingFlags.Public,
+ null, type, new object[] { Path.GetTempPath() });
+ }
+
// To help with creating secure strings to test with.
private static System.Security.SecureString StringToSecureString(string str)
{