Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'LibGit2Sharp.Tests/TestHelpers/Constants.cs')
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/Constants.cs31
1 files changed, 24 insertions, 7 deletions
diff --git a/LibGit2Sharp.Tests/TestHelpers/Constants.cs b/LibGit2Sharp.Tests/TestHelpers/Constants.cs
index 5a389136..85f95c0f 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 @@ namespace LibGit2Sharp.Tests.TestHelpers
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 @@ namespace LibGit2Sharp.Tests.TestHelpers
{
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 @@ namespace LibGit2Sharp.Tests.TestHelpers
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)
{