summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Tests/Utilities
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-08-21 16:39:21 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-08-21 16:39:21 -0400
commit8ba54a682fd7de3756b6ddd262b232cf40d23ea0 (patch)
tree7e44d53b733d95b05b232da46306a0d3d57e9231 /src/StardewModdingAPI.Tests/Utilities
parent674ad0d90f8780130a5fcefb3869acfe2315df2a (diff)
parenteea5100acea0bceaf440f9d1bd50ee2b24cf8ebc (diff)
downloadSMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.gz
SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.bz2
SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI.Tests/Utilities')
-rw-r--r--src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs b/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs
index 95d0d74f..03cd26c9 100644
--- a/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs
+++ b/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
using NUnit.Framework;
+using StardewModdingAPI.Framework;
namespace StardewModdingAPI.Tests.Utilities
{
@@ -206,6 +208,51 @@ namespace StardewModdingAPI.Tests.Utilities
return version.IsBetween(lower, upper);
}
+ /****
+ ** 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.")]
+ [TestCase("1.0")]
+ [TestCase("1.01")]
+ [TestCase("1.02")]
+ [TestCase("1.03")]
+ [TestCase("1.04")]
+ [TestCase("1.05")]
+ [TestCase("1.051")]
+ [TestCase("1.051b")]
+ [TestCase("1.06")]
+ [TestCase("1.07")]
+ [TestCase("1.07a")]
+ [TestCase("1.1")]
+ [TestCase("1.11")]
+ [TestCase("1.2")]
+ [TestCase("1.2.15")]
+ public void GameVersion(string versionStr)
+ {
+ // act
+ GameVersion version = new GameVersion(versionStr);
+
+ // assert
+ Assert.AreEqual(versionStr, version.ToString(), "The game version did not round-trip to the same value.");
+ Assert.IsTrue(version.IsOlderThan(new SemanticVersion("1.2.30")), "The game version should be considered older than the later semantic versions.");
+ }
+
/*********
** Private methods