public void CompareTo_InvalidType() { var semver = new SemanticVersion(1, 0, 0); var obj = new Object(); semver.CompareTo(obj); }
public void CompareTo_Equals() { var semver1 = new SemanticVersion(1, 0, 0); var semver2 = semver1.Clone(); Assert.IsTrue(semver1.Equals(semver2)); }
public void CompareTo_Equals_NotEqual() { var semver1 = new SemanticVersion(1, 0, 0); var semver2 = semver1.IncrementPatch(); Assert.IsTrue(!semver1.Equals(semver2)); }
public void Clonable() { var semver1 = new SemanticVersion(1, 0, 0); var semver2 = semver1.Clone(); Assert.IsTrue(!Object.ReferenceEquals(semver1, semver2)); }
public void CompareTo_PatchVersion() { var earlierSemVer = new SemanticVersion(1, 1, 1); var laterSemVer = new SemanticVersion(1, 1, 3); Assert.IsTrue(earlierSemVer.CompareTo(laterSemVer) == (int)Summerset.SemanticVersion.VersionTime.Earlier); Assert.IsTrue(laterSemVer.CompareTo(earlierSemVer) == (int)Summerset.SemanticVersion.VersionTime.Later); }
public void CompareTo_PrereleaseVersions() { var earlierSemVer = new SemanticVersion(1, 0, 0, "Alpha"); var laterSemVer = new SemanticVersion(1, 0, 0, "RC.1"); Assert.IsTrue(earlierSemVer.CompareTo(laterSemVer) == (int)Summerset.SemanticVersion.VersionTime.Earlier); Assert.IsTrue(laterSemVer.CompareTo(earlierSemVer) == (int)Summerset.SemanticVersion.VersionTime.Later); }
public void ToString_Method_PrereleaseSuffix() { var semver = new SemanticVersion("1.0.0-RC.1"); var semverString = semver.ToString(); StringAssert.Matches(semverString, new Regex("^1.0.0-RC.1$")); }
public void Increment_Patch_Version() { var versionString = "1.2.3-RC.1"; var semver = new SemanticVersion(versionString); // test with a version string that isn't kept var incrementVersion = semver.IncrementPatch(); Assert.AreEqual<uint>(1, incrementVersion.Major); Assert.AreEqual<uint>(2, incrementVersion.Minor); Assert.AreEqual<uint>(4, incrementVersion.Patch); Assert.IsTrue(string.IsNullOrWhiteSpace(incrementVersion.PreReleaseIdentifier)); // redeclare -> this time keep the prerelease identifier incrementVersion = semver.IncrementPatch(true); Assert.AreEqual<uint>(1, incrementVersion.Major); Assert.AreEqual<uint>(2, incrementVersion.Minor); Assert.AreEqual<uint>(4, incrementVersion.Patch); Assert.AreEqual<string>("RC.1", incrementVersion.PreReleaseIdentifier); // test that the original version was unaffected Assert.AreEqual<uint>(1, semver.Major); Assert.AreEqual<uint>(2, semver.Minor); Assert.AreEqual<uint>(3, semver.Patch); Assert.AreEqual<string>("RC.1", semver.PreReleaseIdentifier); }
public void Constructor_FromNumerics_InvalidPrereleaseString_TrailingPeriod() { var illegalSemVer = new SemanticVersion(1, 1, 1, "."); }
/// <summary> /// Compares the version instances and returns an integer that indicates their relationship. <see cref="VersionTime"/>. /// </summary> /// <param name="other">The instance to compare to this instance</param> /// <returns>-1 if the current version is earlier than the comparison; 0 when the two are equal; 1 when the current version is later than the comparison version.</returns> public int CompareTo(SemanticVersion other) { // cast to an object, and call the other overload of this method var otherObj = other as Object; return this.CompareTo(otherObj); }
public void Constructor_ValidString_WithPreReleaseString() { var versionString = "1.2.3-RC.1"; // test that it builds. var semver = new SemanticVersion(versionString); // make sure our properties read out properly Assert.AreEqual<uint>(1, semver.Major); Assert.AreEqual<uint>(2, semver.Minor); Assert.AreEqual<uint>(3, semver.Patch); Assert.AreEqual<string>("RC.1", semver.PreReleaseIdentifier); Assert.AreEqual<bool>(true, semver.IsPreRelease); }
public void Constructor_ValidString_NoPreReleaseString() { var versionString = "1.2.3"; // test that it builds. var semver = new SemanticVersion(versionString); // make sure our properties read out properly Assert.AreEqual<uint>(1, semver.Major); Assert.AreEqual<uint>(2, semver.Minor); Assert.AreEqual<uint>(3, semver.Patch); Assert.IsTrue(string.IsNullOrWhiteSpace(semver.PreReleaseIdentifier)); Assert.AreEqual<bool>(false, semver.IsPreRelease); }
public void Constructor_InvalidString_InvalidPrereleaseString() { var versionString = "1.2.3abcdefg"; var semver = new SemanticVersion(versionString); }
public void Constructor_InvalidString_AlphaCharactersIn() { var versionString = "1.AAAAA.3"; var semver = new SemanticVersion(versionString); }
public void Constructor_FromNumerics_ValidPrereleaseString_LeadingHyphen() { var semver = new SemanticVersion(1, 0, 0, "-RC.1"); Assert.AreEqual<uint>(1, semver.Major); Assert.AreEqual<uint>(0, semver.Minor); Assert.AreEqual<uint>(0, semver.Patch); StringAssert.Matches(semver.PreReleaseIdentifier, new Regex(@"^RC\.1$")); }
public void Constructor_FromNumerics_NoPrereleaseString() { var semver = new SemanticVersion(1, 0, 0); Assert.AreEqual<uint>(1, semver.Major); Assert.AreEqual<uint>(0, semver.Minor); Assert.AreEqual<uint>(0, semver.Patch); Assert.IsTrue(string.IsNullOrWhiteSpace(semver.PreReleaseIdentifier)); }
public void Equals_InvalidType() { var semver = new SemanticVersion(1, 0, 0); semver.Equals(new Object()); }
public void Equals_ValueEquality() { var semver1 = new SemanticVersion(1, 0, 0); var semver2 = semver1.Clone(); Assert.IsTrue(semver1.Equals(semver2)); }
/// <summary> /// Indicates whether two SemanticVersion instances are equal. This is value comparison, not reference comparison. /// </summary> /// <param name="other">The instance to compare to this instance.</param> /// <returns><c>true</c> if the instances are equal. Otherwise <c>false</c>.</returns> public bool Equals(SemanticVersion other) { return (VersionTime)this.CompareTo(other) == VersionTime.Same ? true : false; }
public void Constructor_FromNumerics_InvalidPrereleaseString_IllegalCharacters() { var illegalSemVer = new SemanticVersion(1, 1, 1, "-@#$"); }