diff options
Diffstat (limited to 'src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs')
-rw-r--r-- | src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs b/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs index db46aee4..03cd26c9 100644 --- a/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs +++ b/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; using NUnit.Framework; using StardewModdingAPI.Framework; @@ -208,6 +209,22 @@ namespace StardewModdingAPI.Tests.Utilities } /**** + ** Serialisable + ****/ + [Test(Description = "Assert that SemanticVersion can be round-tripped through JSON with no special configuration.")] + [TestCase("1.0")] + public void Serialisable(string versionStr) + { + // act + string json = JsonConvert.SerializeObject(new SemanticVersion(versionStr)); + SemanticVersion after = JsonConvert.DeserializeObject<SemanticVersion>(json); + + // assert + Assert.IsNotNull(after, "The semantic version after deserialisation is unexpectedly null."); + Assert.AreEqual(versionStr, after.ToString(), "The semantic version after deserialisation doesn't match the input version."); + } + + /**** ** GameVersion ****/ [Test(Description = "Assert that the GameVersion subclass correctly parses legacy game versions.")] |