31 lines
933 B
C#
31 lines
933 B
C#
using Explorer.Application;
|
|
|
|
namespace Explorer.Application.Tests;
|
|
|
|
public class SevenZipLocatorTests
|
|
{
|
|
[Fact]
|
|
public void Prefers_the_configured_path_when_it_exists()
|
|
{
|
|
var path = @"C:\Tools\7z.exe";
|
|
Assert.Equal(path, SevenZipLocator.Find(path, fileExists: p => p == path, pathVariable: ""));
|
|
}
|
|
|
|
[Fact]
|
|
public void Finds_7z_on_PATH_when_not_configured()
|
|
{
|
|
var found = SevenZipLocator.Find(
|
|
null,
|
|
fileExists: p => p.Equals(@"D:\bin\7z.exe", StringComparison.OrdinalIgnoreCase),
|
|
pathVariable: @"C:\Windows;D:\bin");
|
|
Assert.Equal(@"D:\bin\7z.exe", found);
|
|
}
|
|
|
|
[Fact]
|
|
public void Returns_null_when_7zip_is_missing()
|
|
{
|
|
Assert.Null(SevenZipLocator.Find(null, fileExists: _ => false, pathVariable: @"C:\none"));
|
|
Assert.Contains("7-Zip", SevenZipLocator.MissingHint, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
}
|