diff options
author | atravita-mods <94934860+atravita-mods@users.noreply.github.com> | 2022-11-11 06:38:35 -0500 |
---|---|---|
committer | atravita-mods <94934860+atravita-mods@users.noreply.github.com> | 2022-11-11 06:38:35 -0500 |
commit | 4ca546a7a8d5e0f6c9e0df7370f4e6c858d5b69b (patch) | |
tree | 9339b96dc5aa445201698f93fc2061ad0c040269 /src/SMAPI.Tests/Core/AssetNameTests.cs | |
parent | 303b3924ae3ef905d77b9d7ef0f9efc70e58c2b8 (diff) | |
download | SMAPI-4ca546a7a8d5e0f6c9e0df7370f4e6c858d5b69b.tar.gz SMAPI-4ca546a7a8d5e0f6c9e0df7370f4e6c858d5b69b.tar.bz2 SMAPI-4ca546a7a8d5e0f6c9e0df7370f4e6c858d5b69b.zip |
directly add tests over the trailing slash.
Diffstat (limited to 'src/SMAPI.Tests/Core/AssetNameTests.cs')
-rw-r--r-- | src/SMAPI.Tests/Core/AssetNameTests.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/SMAPI.Tests/Core/AssetNameTests.cs b/src/SMAPI.Tests/Core/AssetNameTests.cs index fdaa2c01..cd4d0473 100644 --- a/src/SMAPI.Tests/Core/AssetNameTests.cs +++ b/src/SMAPI.Tests/Core/AssetNameTests.cs @@ -265,6 +265,26 @@ namespace SMAPI.Tests.Core return name.StartsWith(otherAssetName, allowPartialWord: true, allowSubfolder: allowSubfolder); } + // the enumerator strips the trailing path seperator + // 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_PrefixHasSeperator(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 |