|
1 | 1 | using System.IO; |
| 2 | +using System.Linq; |
| 3 | +using System.Threading; |
2 | 4 | using DiffEngine; |
3 | 5 | using Xunit; |
4 | 6 | using Xunit.Abstractions; |
@@ -26,27 +28,36 @@ public void Kill() |
26 | 28 | DiffRunner.Kill(tempFile, targetFile); |
27 | 29 | #endregion |
28 | 30 | } |
| 31 | +#if NETCOREAPP3_1 |
29 | 32 |
|
30 | | - //static string diffToolPath = Path.GetFullPath(Path.Combine(AssemblyLocation.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe")); |
| 33 | + static string diffToolPath = Path.GetFullPath(Path.Combine(AssemblyLocation.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe")); |
31 | 34 |
|
32 | | - //[Fact] |
33 | | - //public void LaunchAndKill() |
34 | | - //{ |
35 | | - // DiffTools.AddCustomTool( |
36 | | - // supportsAutoRefresh: true, |
37 | | - // isMdi: false, |
38 | | - // supportsText: true, |
39 | | - // requiresTarget: true, |
40 | | - // buildArguments: (path1, path2) => $"\"{path1}\" \"{path2}\"", |
41 | | - // exePath: diffToolPath, |
42 | | - // binaryExtensions: new[] {"knownBin"}); |
43 | | - // var tempFile = Path.Combine(SourceDirectory, "DiffRunner.file1.txt"); |
44 | | - // var targetFile = Path.Combine(SourceDirectory, "DiffRunner.file2.txt"); |
45 | | - // DiffRunner.Launch(tempFile, targetFile); |
46 | | - // Assert.NotEmpty(ProcessCleanup.FindAll()); |
47 | | - // DiffRunner.Kill(tempFile, targetFile); |
48 | | - // Assert.Empty(ProcessCleanup.FindAll()); |
49 | | - //} |
| 35 | + [Fact] |
| 36 | + public void LaunchAndKill() |
| 37 | + { |
| 38 | + DiffTools.AddCustomTool( |
| 39 | + supportsAutoRefresh: true, |
| 40 | + isMdi: false, |
| 41 | + supportsText: true, |
| 42 | + requiresTarget: true, |
| 43 | + buildArguments: (path1, path2) => $"\"{path1}\" \"{path2}\"", |
| 44 | + exePath: diffToolPath, |
| 45 | + binaryExtensions: new[] {"knownBin"}); |
| 46 | + var tempFile = Path.Combine(SourceDirectory, "DiffRunner.file1.txt"); |
| 47 | + var targetFile = Path.Combine(SourceDirectory, "DiffRunner.file2.txt"); |
| 48 | + DiffRunner.Launch(tempFile, targetFile); |
| 49 | + Thread.Sleep(100); |
| 50 | + Assert.True(IsRunning()); |
| 51 | + DiffRunner.Kill(tempFile, targetFile); |
| 52 | + Thread.Sleep(100); |
| 53 | + Assert.False(IsRunning()); |
| 54 | + } |
| 55 | + |
| 56 | + static bool IsRunning() |
| 57 | + { |
| 58 | + return ProcessCleanup.FindAll().Any(x => x.Command.Contains("FakeDiffTool")); |
| 59 | + } |
| 60 | +#endif |
50 | 61 |
|
51 | 62 | public DiffRunnerTests(ITestOutputHelper output) : |
52 | 63 | base(output) |
|
0 commit comments