Fix issues with parentable path on Linux

This commit is contained in:
Matt Nadareski
2024-04-16 11:50:31 -04:00
parent 1bdb483205
commit c19b59dc1c
2 changed files with 26 additions and 3 deletions

View File

@@ -18,6 +18,14 @@ namespace SabreTools.IO.Test
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", true, "SubDir-Filename.ext")]
public void NormalizedFileNameTest(string current, string? parent, bool sanitize, string? expected)
{
// Hack to support Windows paths on Linux for testing only
if (System.IO.Path.DirectorySeparatorChar == '/')
{
current = current.Replace('\\', '/');
parent = parent?.Replace('\\', '/');
expected = expected?.Replace('\\', '/');
}
var path = new ParentablePath(current, parent);
string? actual = path.GetNormalizedFileName(sanitize);
Assert.Equal(expected, actual);
@@ -62,6 +70,15 @@ namespace SabreTools.IO.Test
if (expected?.Contains("%cd%") == true)
expected = expected.Replace("%cd%", Environment.CurrentDirectory.TrimEnd('\\', '/'));
// Hack to support Windows paths on Linux for testing only
if (System.IO.Path.DirectorySeparatorChar == '/')
{
current = current.Replace('\\', '/');
parent = parent?.Replace('\\', '/');
outDir = outDir?.Replace('\\', '/');
expected = expected?.Replace('\\', '/');
}
var path = new ParentablePath(current, parent);
string? actual = path.GetOutputPath(outDir, inplace);
Assert.Equal(expected, actual);