Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DiffEngine.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
global using EmptyFiles;
global using EmptyFiles;
56 changes: 56 additions & 0 deletions src/DiffEngine.Tests/WindowsProcessTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#if NET5_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
public class WindowsProcessTests(ITestOutputHelper output) :
XunitContextBase(output)
{
[Theory]
[InlineData("\"C:\\Program Files\\Beyond Compare 4\\BComp.exe\" C:\\temp\\file.1.txt C:\\temp\\file.2.txt", true)]
[InlineData("notepad.exe C:\\Users\\test\\doc.1.txt C:\\Users\\test\\doc.2.txt", true)]
[InlineData("\"C:\\diff\\tool.exe\" D:\\path\\to\\source.1.cs D:\\path\\to\\target.2.cs", true)]
[InlineData("code.exe --diff file.a.b file.c.d", true)]
[InlineData("app.exe path.with.dots path.more.dots", true)]
public void MatchesPattern_WithTwoFilePaths_ReturnsTrue(string commandLine, bool expected)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

Assert.Equal(expected, WindowsProcess.MatchesPattern(commandLine));
}

[Theory]
[InlineData("notepad.exe")]
[InlineData("notepad.exe C:\\temp\\file.txt")]
[InlineData("cmd.exe /c dir")]
[InlineData("explorer.exe")]
[InlineData("")]
[InlineData("singleword")]
[InlineData("app.exe onepath.with.dots")]
public void MatchesPattern_WithoutTwoFilePaths_ReturnsFalse(string commandLine)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

Assert.False(WindowsProcess.MatchesPattern(commandLine));
}

[Fact]
public void FindAll_ReturnsProcessCommands()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

var result = WindowsProcess.FindAll();
Assert.NotNull(result);
foreach (var cmd in result)
{
Debug.WriteLine($"{cmd.Process}: {cmd.Command}");
}
}
}
7 changes: 2 additions & 5 deletions src/DiffEngine/DiffEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<PropertyGroup>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net472;net48;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<AllowUnsafeBlocks Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Using Include="DiffEngine" />
<Using Include="System.Management" />
<Using Include="System.Text" />
<Using Include="Microsoft.Win32.SafeHandles" />
<Using Include="System.Diagnostics.CodeAnalysis" />
<Using Include="System.Net" />
Expand All @@ -19,10 +20,6 @@
<PackageReference Include="EmptyFiles" PrivateAssets="None" />
<PackageReference Include="Fody" PrivateAssets="all" />
<PackageReference Include="Polyfill" PrivateAssets="all" />
<PackageReference Include="System.Management" />
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
</ItemGroup>
<Target Name="CheckPackageVersion" BeforeTargets="Build">
<Error Condition="'%(PackageVersion.Identity)' == 'System.Management' AND '%(PackageVersion.Version)' != '8.0.0'" Text="Invalid package version for System.Management. Expected: 8.0.0." />
</Target>
</Project>
Loading