summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests/Utilities
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-09-02 18:54:56 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-09-02 18:54:56 -0400
commit8789b7efa816aab0f4ce9d3149c26b8033e0b0a5 (patch)
tree392f2f010ebcb7f795c8e1cc75286396f3fa8e44 /src/SMAPI.Tests/Utilities
parent5848a355bac789ba8d879df64bea400d17ea83f5 (diff)
downloadSMAPI-8789b7efa816aab0f4ce9d3149c26b8033e0b0a5.tar.gz
SMAPI-8789b7efa816aab0f4ce9d3149c26b8033e0b0a5.tar.bz2
SMAPI-8789b7efa816aab0f4ce9d3149c26b8033e0b0a5.zip
prepare path utilities for the upcoming Stardew Valley 1.5.5
The game will use Linux-style paths for assets on all platforms, which will break the current equivalence between path and asset name formats.
Diffstat (limited to 'src/SMAPI.Tests/Utilities')
-rw-r--r--src/SMAPI.Tests/Utilities/PathUtilitiesTests.cs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/SMAPI.Tests/Utilities/PathUtilitiesTests.cs b/src/SMAPI.Tests/Utilities/PathUtilitiesTests.cs
index 5a342974..c18f47a5 100644
--- a/src/SMAPI.Tests/Utilities/PathUtilitiesTests.cs
+++ b/src/SMAPI.Tests/Utilities/PathUtilitiesTests.cs
@@ -1,3 +1,4 @@
+using System.IO;
using NUnit.Framework;
using StardewModdingAPI.Toolkit.Utilities;
@@ -175,9 +176,30 @@ namespace SMAPI.Tests.Utilities
}
/****
- ** NormalizePathSeparators
+ ** NormalizeAssetName
****/
- [Test(Description = "Assert that PathUtilities.NormalizePathSeparators normalizes paths correctly.")]
+ [Test(Description = "Assert that PathUtilities.NormalizeAssetName normalizes paths correctly.")]
+ [TestCaseSource(nameof(PathUtilitiesTests.SamplePaths))]
+ public void NormalizeAssetName(SamplePath path)
+ {
+ if (Path.IsPathRooted(path.OriginalPath) || path.OriginalPath.StartsWith("/") || path.OriginalPath.StartsWith("\\"))
+ Assert.Ignore("Absolute paths can't be used as asset names.");
+
+ // act
+ string normalized = PathUtilities.NormalizeAssetName(path.OriginalPath);
+
+ // assert
+#if SMAPI_FOR_WINDOWS
+ Assert.AreEqual(path.NormalizedOnWindows, normalized);
+#else
+ Assert.AreEqual(path.NormalizedOnUnix, normalized);
+#endif
+ }
+
+ /****
+ ** NormalizePath
+ ****/
+ [Test(Description = "Assert that PathUtilities.NormalizePath normalizes paths correctly.")]
[TestCaseSource(nameof(PathUtilitiesTests.SamplePaths))]
public void NormalizePath(SamplePath path)
{