|
1 | | -using System.Text.RegularExpressions; |
| 1 | +using System; |
| 2 | +using System.IO; |
| 3 | +using System.Text.RegularExpressions; |
| 4 | +using LibGit2Sharp.Core; |
2 | 5 | using LibGit2Sharp.Tests.TestHelpers; |
3 | 6 | using Xunit; |
4 | 7 |
|
@@ -49,5 +52,35 @@ public void TryingToResetNativeLibraryPathAfterLoadedThrows() |
49 | 52 |
|
50 | 53 | Assert.Throws<LibGit2SharpException>(() => { GlobalSettings.NativeLibraryPath = "C:/Foo"; }); |
51 | 54 | } |
| 55 | + |
| 56 | + [ConditionalFact(typeof(NetFramework))] |
| 57 | + public void LoadFromSpecifiedPath() |
| 58 | + { |
| 59 | +#if NET461 |
| 60 | + var nativeDllFileName = NativeDllName.Name + ".dll"; |
| 61 | + |
| 62 | + var testAppExe = typeof(TestApp).Assembly.Location; |
| 63 | + var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); |
| 64 | + var platformDir = Path.Combine(tempDir, "plat"); |
| 65 | + |
| 66 | + try |
| 67 | + { |
| 68 | + Directory.CreateDirectory(Path.Combine(platformDir, "x86")); |
| 69 | + Directory.CreateDirectory(Path.Combine(platformDir, "x64")); |
| 70 | + |
| 71 | + File.Copy(Path.Combine(GlobalSettings.NativeLibraryPath, "x86", nativeDllFileName), Path.Combine(platformDir, "x86", nativeDllFileName)); |
| 72 | + File.Copy(Path.Combine(GlobalSettings.NativeLibraryPath, "x64", nativeDllFileName), Path.Combine(platformDir, "x64", nativeDllFileName)); |
| 73 | + |
| 74 | + var (output, exitCode) = ProcessHelper.RunProcess(testAppExe, arguments: $@"{NativeDllName.Name} ""{platformDir}""", workingDirectory: tempDir); |
| 75 | + |
| 76 | + Assert.Empty(output); |
| 77 | + Assert.Equal(0, exitCode); |
| 78 | + } |
| 79 | + finally |
| 80 | + { |
| 81 | + DirectoryHelper.DeleteDirectory(tempDir); |
| 82 | + } |
| 83 | +#endif |
| 84 | + } |
52 | 85 | } |
53 | 86 | } |
0 commit comments