Skip to content

Commit

Permalink
Pathing fixes in DataRelativePathTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Jul 22, 2024
1 parent 44eae43 commit c5118f3
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using System.Runtime.InteropServices;
using FluentAssertions;
using Mutagen.Bethesda.Assets;
using Mutagen.Bethesda.Plugins.Exceptions;
using Noggog;
Expand All @@ -8,20 +9,22 @@ namespace Mutagen.Bethesda.UnitTests.Plugins.Assets;

public class DataRelativePathTests
{
static bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
static string absPrefix = isWindows ? "C:\\" : "/";
static readonly string DataPath = Path.Combine("Meshes" ,"Clutter", "MyMesh.nif");

[Fact]
public void AbsolutePath()
{
var path = "C:\\Skyrim\\Data\\Meshes\\Clutter\\MyMesh.nif";
var path = @$"{absPrefix}{Path.Combine("Skyrim", "Data", "Meshes", "Clutter", "MyMesh.nif")}";
var link = new DataRelativePath(path);
link.Path.Should().Be(DataPath);
}

[Fact]
public void DataRelativePath()
{
var path = "Data\\Meshes\\Clutter\\MyMesh.nif";
var path = Path.Combine("Data", "Meshes", "Clutter", "MyMesh.nif");
var link = new DataRelativePath(path);
link.Path.Should().Be(DataPath);
}
Expand All @@ -30,23 +33,23 @@ public void DataRelativePath()
[Fact]
public void DataRelativePathWithPrefix()
{
var path = "SomeFolder\\Data\\Meshes\\Clutter\\MyMesh.nif";
var path = Path.Combine("SomeFolder", "Data", "Meshes", "Clutter", "MyMesh.nif");
var link = new DataRelativePath(path);
link.Path.Should().Be(DataPath);
}

[Fact]
public void PrefixedDataRelativePath()
{
var path = "\\Data\\Meshes\\Clutter\\MyMesh.nif";
var path = $"{Path.DirectorySeparatorChar}{Path.Combine("Data", "Meshes", "Clutter", "MyMesh.nif")}";
var link = new DataRelativePath(path);
link.Path.Should().Be(DataPath);
}

[Fact]
public void FirstLevelChildRelativePath()
{
var path = "Clutter\\MyMesh.nif";
var path = Path.Combine("Clutter", "MyMesh.nif");
var link = new DataRelativePath(path);
link.Path.Should().Be(path);
}
Expand All @@ -56,8 +59,7 @@ public void NoDataFolderInAbsolutePath()
{
Assert.Throws<AssetPathMisalignedException>(() =>
{
new DataRelativePath(
"C:\\Skyrim\\NoDataPath\\MyMesh.nif");
new DataRelativePath($"{absPrefix}{Path.Combine("Skyrim", "NoDataPath", "MyMesh.nif")}");
});
}
}

0 comments on commit c5118f3

Please sign in to comment.