21 using NUnit.Framework;
29 [TestCase(
"0.1.2", 0, 1, 2,
"",
"")]
30 [TestCase(
"10.20.30-0.0.1", 10, 20, 30,
"0.0.1",
"")]
31 [TestCase(
"0.1.2-alpha.1", 0, 1, 2,
"alpha.1",
"")]
32 [TestCase(
"0.1.2-0.0.1+githash", 0, 1, 2,
"0.0.1",
"githash")]
33 [TestCase(
"0.1.2+githash", 0, 1, 2,
"",
"githash")]
34 public void ParseSemanticVersion(
string version,
int major,
int minor,
int patch,
35 string preRelease,
string build)
38 Assert.AreEqual(major, semVer.Major,
"Major version does not match");
39 Assert.AreEqual(minor, semVer.Minor,
"Minor version does not match");
40 Assert.AreEqual(patch, semVer.Patch,
"Patch number does not match");
41 Assert.AreEqual(build, semVer.Build,
"Build information does not match");
55 public void InvalidVersionThrowsError()
61 [TestCase(
"1.0.0",
"1.0.1")]
62 [TestCase(
"1.0.0",
"1.1.0")]
63 [TestCase(
"1.0.1",
"2.0.0")]
64 [TestCase(
"1.1.1",
"2.0.0")]
65 [TestCase(
"1.1.1-0.1.2",
"1.1.1")]
66 [TestCase(
"1.1.1-alpha.10",
"1.1.1")]
67 [TestCase(
"1.1.1-beta.2",
"1.1.1")]
68 [TestCase(
"1.1.1-alpha.2",
"1.1.1-beta.1")]
69 [TestCase(
"1.1.1-rc.1",
"1.1.1-rc.2")]
70 public void CompareVersions(
string lower,
string higher)
74 Assert.Greater(higherVersion, lowerVersion);
75 Assert.True(lowerVersion < higherVersion);
76 Assert.True(higherVersion > lowerVersion);
81 [TestCase(
"1.0.0-3.2.1")]
82 [TestCase(
"1.0.0-alpha.3")]
83 [TestCase(
"1.0.0-rc.2")]
84 [TestCase(
"1.0.0+20160507")]
85 [TestCase(
"1.0.0-alpha.3+20160507")]
86 public void Idempotence(
string versionString)
89 Assert.AreEqual(versionString, v.
ToString());
Class that handles semantic versioning.
override string ToString()
Returns the full version string.