diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-08-14 07:55:21 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-08-14 07:55:21 -0400 |
commit | 67b1a8398f665a745f57f6d53532e504979ea40f (patch) | |
tree | 8633cb5f814c96056b93e0edf3a3560ebd10cc90 /src/StardewModdingAPI.Tests/Utilities | |
parent | 56c66ca4e550ae482ad82dd7f87b0b1fa6adfb60 (diff) | |
download | SMAPI-67b1a8398f665a745f57f6d53532e504979ea40f.tar.gz SMAPI-67b1a8398f665a745f57f6d53532e504979ea40f.tar.bz2 SMAPI-67b1a8398f665a745f57f6d53532e504979ea40f.zip |
fix SemanticVersion not being deserialisable through Json.NET
Diffstat (limited to 'src/StardewModdingAPI.Tests/Utilities')
-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.")] |