コード例 #1
0
        public void CompareTo_InvalidType()
        {
            var semver = new SemanticVersion(1, 0, 0);
            var obj = new Object();

            semver.CompareTo(obj);
        }
コード例 #2
0
        public void CompareTo_Equals()
        {
            var semver1 = new SemanticVersion(1, 0, 0);
            var semver2 = semver1.Clone();

            Assert.IsTrue(semver1.Equals(semver2));
        }
コード例 #3
0
        public void CompareTo_Equals_NotEqual()
        {
            var semver1 = new SemanticVersion(1, 0, 0);
            var semver2 = semver1.IncrementPatch();

            Assert.IsTrue(!semver1.Equals(semver2));
        }
コード例 #4
0
        public void Clonable()
        {
            var semver1 = new SemanticVersion(1, 0, 0);
            var semver2 = semver1.Clone();

            Assert.IsTrue(!Object.ReferenceEquals(semver1, semver2));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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$"));
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 public void Constructor_FromNumerics_InvalidPrereleaseString_TrailingPeriod()
 {
     var illegalSemVer = new SemanticVersion(1, 1, 1, ".");
 }
コード例 #10
0
        /// <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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public void Constructor_InvalidString_InvalidPrereleaseString()
        {
            var versionString       = "1.2.3abcdefg";

            var semver = new SemanticVersion(versionString);
        }
コード例 #14
0
        public void Constructor_InvalidString_AlphaCharactersIn()
        {
            var versionString       = "1.AAAAA.3";

            var semver = new SemanticVersion(versionString);
        }
コード例 #15
0
 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$"));
 }
コード例 #16
0
 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));
 }
コード例 #17
0
 public void Equals_InvalidType()
 {
     var semver = new SemanticVersion(1, 0, 0);
     semver.Equals(new Object());
 }
コード例 #18
0
        public void Equals_ValueEquality()
        {
            var semver1 = new SemanticVersion(1, 0, 0);
            var semver2 = semver1.Clone();

            Assert.IsTrue(semver1.Equals(semver2));
        }
コード例 #19
0
 /// <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;
 }
コード例 #20
0
 public void Constructor_FromNumerics_InvalidPrereleaseString_IllegalCharacters()
 {
     var illegalSemVer = new SemanticVersion(1, 1, 1, "-@#$");
 }