diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-07-10 13:30:20 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-07-10 13:30:20 -0400 |
commit | 61d13d370c07bec029336890eec9501a8efc3056 (patch) | |
tree | 85cf1d0b812980ea82cf03a66fc1e89e3f91ccbd /src/StardewModdingAPI.Tests | |
parent | 7bf0c660888ab3082f95b83226a6a55c08b62959 (diff) | |
download | SMAPI-61d13d370c07bec029336890eec9501a8efc3056.tar.gz SMAPI-61d13d370c07bec029336890eec9501a8efc3056.tar.bz2 SMAPI-61d13d370c07bec029336890eec9501a8efc3056.zip |
fail mods if their unique ID isn't unique (#323)
Diffstat (limited to 'src/StardewModdingAPI.Tests')
-rw-r--r-- | src/StardewModdingAPI.Tests/Core/ModResolverTests.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs index e6ec632a..9b46c5d2 100644 --- a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs +++ b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs @@ -179,6 +179,26 @@ namespace StardewModdingAPI.Tests.Core mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<string>()), Times.Once, "The validation did not fail the metadata."); } +#if SMAPI_2_0 + [Test(Description = "Assert that validation fails when multiple mods have the same unique ID.")] + public void ValidateManifests_DuplicateUniqueID_Fails() + { + // arrange + Mock<IModMetadata> modA = this.GetMetadata("Mod A", new string[0], allowStatusChange: true); + Mock<IModMetadata> modB = this.GetMetadata(this.GetManifest("Mod A", "1.0", manifest => manifest.Name = "Mod B"), allowStatusChange: true); + Mock<IModMetadata> modC = this.GetMetadata("Mod C", new string[0], allowStatusChange: false); + foreach (Mock<IModMetadata> mod in new[] { modA, modB, modC }) + this.SetupMetadataForValidation(mod); + + // act + new ModResolver().ValidateManifests(new[] { modA.Object, modB.Object }, apiVersion: new SemanticVersion("1.0")); + + // assert + modA.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<string>()), Times.Once, "The validation did not fail the first mod with a unique ID."); + modB.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<string>()), Times.Once, "The validation did not fail the second mod with a unique ID."); + } +#endif + [Test(Description = "Assert that validation fails when the manifest references a DLL that does not exist.")] public void ValidateManifests_Valid_Passes() { |