mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix parentable path tests
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.IO;
|
||||
using Xunit;
|
||||
|
||||
@@ -7,10 +6,7 @@ namespace SabreTools.Test.IO
|
||||
{
|
||||
public class ParentablePathTests
|
||||
{
|
||||
// TODO: Re-enable test when SabreTools.IO is updated
|
||||
//[Theory]
|
||||
[InlineData(null, null, false, null)]
|
||||
[InlineData(null, null, true, null)]
|
||||
[Theory]
|
||||
[InlineData("", null, false, null)]
|
||||
[InlineData("", null, true, null)]
|
||||
[InlineData(" ", null, false, null)]
|
||||
@@ -21,18 +17,14 @@ namespace SabreTools.Test.IO
|
||||
[InlineData("C:\\Directory\\Filename.ext", "C:\\Directory\\Filename.ext", true, "Filename.ext")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", false, "SubDir\\Filename.ext")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", true, "SubDir-Filename.ext")]
|
||||
public void NormalizedFileNameTest(string current, string parent, bool sanitize, string expected)
|
||||
public void NormalizedFileNameTest(string current, string? parent, bool sanitize, string? expected)
|
||||
{
|
||||
// TODO: Fix SabreTools.IO to trim the paths automatically
|
||||
// TODO: Fix SabreTools.IO to normalize more safely
|
||||
var path = new ParentablePath(current?.Trim(), parent?.Trim());
|
||||
string actual = path.GetNormalizedFileName(sanitize);
|
||||
var path = new ParentablePath(current, parent);
|
||||
string? actual = path.GetNormalizedFileName(sanitize);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null, null, false, null)]
|
||||
[InlineData(null, null, null, true, null)]
|
||||
[InlineData("", null, null, false, null)]
|
||||
[InlineData("", null, null, true, null)]
|
||||
[InlineData(" ", null, null, false, null)]
|
||||
@@ -43,8 +35,6 @@ namespace SabreTools.Test.IO
|
||||
[InlineData("C:\\Directory\\Filename.ext", "C:\\Directory\\Filename.ext", null, true, "C:\\Directory")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", null, false, null)]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", null, true, "C:\\Directory\\SubDir")]
|
||||
[InlineData(null, null, "D:\\OutputDirectory", false, null)]
|
||||
[InlineData(null, null, "D:\\OutputDirectory", true, null)]
|
||||
[InlineData("", null, "D:\\OutputDirectory", false, null)]
|
||||
[InlineData("", null, "D:\\OutputDirectory", true, null)]
|
||||
[InlineData(" ", null, "D:\\OutputDirectory", false, null)]
|
||||
@@ -55,8 +45,6 @@ namespace SabreTools.Test.IO
|
||||
[InlineData("C:\\Directory\\Filename.ext", "C:\\Directory\\Filename.ext", "D:\\OutputDirectory", true, "C:\\Directory")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", "D:\\OutputDirectory", false, "D:\\OutputDirectory\\SubDir")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", "D:\\OutputDirectory", true, "C:\\Directory\\SubDir")]
|
||||
[InlineData(null, null, "%cd%", false, null)]
|
||||
[InlineData(null, null, "%cd%", true, null)]
|
||||
[InlineData("", null, "%cd%", false, null)]
|
||||
[InlineData("", null, "%cd%", true, null)]
|
||||
[InlineData(" ", null, "%cd%", false, null)]
|
||||
@@ -67,7 +55,7 @@ namespace SabreTools.Test.IO
|
||||
[InlineData("C:\\Directory\\Filename.ext", "C:\\Directory\\Filename.ext", "%cd%", true, "C:\\Directory")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", "%cd%", false, "%cd%\\Directory\\SubDir")]
|
||||
[InlineData("C:\\Directory\\SubDir\\Filename.ext", "C:\\Directory", "%cd%", true, "C:\\Directory\\SubDir")]
|
||||
public void GetOutputPathTest(string current, string parent, string outDir, bool inplace, string expected)
|
||||
public void GetOutputPathTest(string current, string? parent, string? outDir, bool inplace, string? expected)
|
||||
{
|
||||
// Hacks because I can't use environment vars as parameters
|
||||
if (outDir == "%cd%")
|
||||
@@ -75,9 +63,8 @@ namespace SabreTools.Test.IO
|
||||
if (expected?.Contains("%cd%") == true)
|
||||
expected = expected.Replace("%cd%", Environment.CurrentDirectory.TrimEnd('\\'));
|
||||
|
||||
// TODO: Fix SabreTools.IO to trim the paths automatically
|
||||
var path = new ParentablePath(current?.Trim(), parent?.Trim());
|
||||
string actual = path.GetOutputPath(outDir, inplace);
|
||||
var path = new ParentablePath(current, parent);
|
||||
string? actual = path.GetOutputPath(outDir, inplace);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user