From 4ca546a7a8d5e0f6c9e0df7370f4e6c858d5b69b Mon Sep 17 00:00:00 2001 From: atravita-mods <94934860+atravita-mods@users.noreply.github.com> Date: Fri, 11 Nov 2022 06:38:35 -0500 Subject: directly add tests over the trailing slash. --- src/SMAPI.Tests/Core/AssetNameTests.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/SMAPI.Tests/Core/AssetNameTests.cs') 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 -- cgit