summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests/Core
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-11-11 21:25:01 -0500
committerGitHub <noreply@github.com>2022-11-11 21:25:01 -0500
commit1894cd831e2f31cbdb0baab63ea3638b4b62ff52 (patch)
tree780706844d5eef82d4af8097a76fa657125d2c40 /src/SMAPI.Tests/Core
parenta52f888c3f7098eb06f4ae2e6a3a5b1998470d15 (diff)
parentad2dcc28791eb8026335646474fb2e0766fcc51b (diff)
downloadSMAPI-1894cd831e2f31cbdb0baab63ea3638b4b62ff52.tar.gz
SMAPI-1894cd831e2f31cbdb0baab63ea3638b4b62ff52.tar.bz2
SMAPI-1894cd831e2f31cbdb0baab63ea3638b4b62ff52.zip
Merge pull request #884 from atravita-mods/develop
AssetName.StartsWith - fix yet another case with the trailing slash
Diffstat (limited to 'src/SMAPI.Tests/Core')
-rw-r--r--src/SMAPI.Tests/Core/AssetNameTests.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/SMAPI.Tests/Core/AssetNameTests.cs b/src/SMAPI.Tests/Core/AssetNameTests.cs
index fdaa2c01..2d546ec7 100644
--- a/src/SMAPI.Tests/Core/AssetNameTests.cs
+++ b/src/SMAPI.Tests/Core/AssetNameTests.cs
@@ -265,6 +265,25 @@ namespace SMAPI.Tests.Core
return name.StartsWith(otherAssetName, allowPartialWord: true, allowSubfolder: allowSubfolder);
}
+ // The enumerator strips the trailing path separator, so each of these cases has to be handled on each branch.
+ [TestCase("Mods/SomeMod", "Mods/", false, ExpectedResult = true)]
+ [TestCase("Mods/SomeMod", "Mods", false, ExpectedResult = false)]
+ [TestCase("Mods/Jasper/Data", "Mods/Jas/", false, ExpectedResult = false)]
+ [TestCase("Mods/Jasper/Data", "Mods/Jas", false, ExpectedResult = false)]
+ [TestCase("Mods/Jas", "Mods/Jas/", false, ExpectedResult = false)]
+ [TestCase("Mods/Jas", "Mods/Jas", false, ExpectedResult = true)]
+ public bool StartsWith_PrefixHasSeparator(string mainAssetName, string otherAssetName, bool allowSubfolder)
+ {
+ // arrange
+ mainAssetName = PathUtilities.NormalizeAssetName(mainAssetName);
+
+ // act
+ AssetName name = AssetName.Parse(mainAssetName, _ => null);
+
+ // assert value
+ return name.StartsWith(otherAssetName, allowPartialWord: true, allowSubfolder: allowSubfolder);
+ }
+
/****
** GetHashCode