コード例 #1
0
        public void StringValue_CompareTo_Varies_Nonempty()
        {
            StringValue variesValue = new StringValue(aTestString);

            variesValue.IsVaries = true;

            Assert.IsTrue(variesValue.CompareTo(_testValue) < 0);
        }
コード例 #2
0
        /// <summary>
        /// Compares <see langword="this"/> to the <see cref="AlmostVersion"/> in <paramref name="other"/> using <see cref="Version.CompareTo(Version)"/>
        /// or <see cref="string.CompareTo(string)"/>, depending on the current store.
        /// </summary>
        /// <remarks>
        /// The storage methods of the two objects must be the same, or this will throw an <see cref="InvalidOperationException"/>.
        /// </remarks>
        /// <param name="other">the <see cref="AlmostVersion"/> to compare to</param>
        /// <returns>less than 0 if <paramref name="other"/> is considered bigger than <see langword="this"/>, 0 if equal, and greater than zero if smaller</returns>
        /// <seealso cref="CompareTo(Version)"/>
        public int CompareTo(AlmostVersion other)
        {
            if (other == null) return -1;
            if (StorageMode != other.StorageMode)
                throw new InvalidOperationException("Cannot compare AlmostVersions with different stores!");

            if (StorageMode == StoredAs.SemVer)
                return SemverValue.CompareTo(other.SemverValue);
            else
                return StringValue.CompareTo(other.StringValue);
        }
コード例 #3
0
 public void StringValue_CompareTo_Empty_Nonempty()
 {
     Assert.IsTrue(_emptyTestValue.CompareTo(_testValue) < 0);
 }
コード例 #4
0
 public void StringValue_CompareTo_Indeterminate_Nonempty()
 {
     Assert.IsTrue(_defaultValue.CompareTo(_testValue) < 0);
 }
コード例 #5
0
 public void StringValue_CompareTo_ReferenceEquality()
 {
     Assert.IsTrue(_testValue.CompareTo(_testValue) == 0);
 }