-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathDiffRunnerTests.cs
70 lines (64 loc) · 2.1 KB
/
DiffRunnerTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if NETCOREAPP3_1 && DEBUG
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using DiffEngine;
using Xunit;
using Xunit.Abstractions;
public class DiffRunnerTests :
XunitContextBase
{
[Fact(Skip = "Explicit")]
public void Launch()
{
var tempFile = Path.Combine(SourceDirectory, "DiffRunner.file1.txt");
var targetFile = Path.Combine(SourceDirectory, "DiffRunner.file2.txt");
#region DiffRunnerLaunch
DiffRunner.Launch(tempFile, targetFile);
#endregion
}
[Fact(Skip = "Explicit")]
public void Kill()
{
var tempFile = Path.Combine(SourceDirectory, "DiffRunner.file1.txt");
var targetFile = Path.Combine(SourceDirectory, "DiffRunner.file2.txt");
DiffRunner.Launch(tempFile, targetFile);
#region DiffRunnerKill
DiffRunner.Kill(tempFile, targetFile);
#endregion
}
static string diffToolPath = Path.GetFullPath(Path.Combine(AssemblyLocation.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe"));
[Fact]
public void LaunchAndKill()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}
DiffTools.AddCustomTool(
supportsAutoRefresh: true,
isMdi: false,
supportsText: true,
requiresTarget: true,
buildArguments: (path1, path2) => $"\"{path1}\" \"{path2}\"",
exePath: diffToolPath,
binaryExtensions: new[] {"knownBin"});
var tempFile = Path.Combine(SourceDirectory, "DiffRunner.file1.txt");
var targetFile = Path.Combine(SourceDirectory, "DiffRunner.file2.txt");
DiffRunner.Launch(tempFile, targetFile);
Assert.True(IsRunning());
DiffRunner.Kill(tempFile, targetFile);
Assert.False(IsRunning());
}
static bool IsRunning()
{
Thread.Sleep(500);
return ProcessCleanup.FindAll().Any(x => x.Command.Contains("FakeDiffTool"));
}
public DiffRunnerTests(ITestOutputHelper output) :
base(output)
{
}
}
#endif