Beispiel #1
0
 public int CompareTo(Id that)
 {
     if (this.length > that.length)
     {
         return(1);
     }
     else if (this.length < that.length)
     {
         return(-1);
     }
     else
     {
         int compare = 0;
         for (int i = 0; i < length; i++)
         {
             ComponentId thisCid = this.components[i];
             ComponentId thatCid = that.components[i];
             compare = thisCid.CompareTo(thatCid);
             if (compare > 0)
             {
                 return(1);
             }
             else if (compare < 0)
             {
                 return(-1);
             }
         }
         return(compare);
     }
 }
 /// <summary>
 /// Compare this instance to another object that implements
 /// <see cref="IComponentMetaData"/>.
 /// </summary>
 /// <param name="other">
 /// The <see cref="IComponentMetaData"/> instance to compare to.
 /// </param>
 /// <returns>
 /// &gt;0 if this instance precedes `other` in the sort order.
 /// 0 if they are equal in the sort order.
 /// &lt;0 if `other` precedes this instance in the sort order.
 /// </returns>
 public int CompareTo(IComponentMetaData other)
 {
     if (other == null)
     {
         return(-1);
     }
     return(ComponentId.CompareTo(other.ComponentId));
 }
        public void CompareToTest()
        {
            ComponentId target      = new ComponentId(); // TODO: 初始化为适当的值
            object      otherObject = null;              // TODO: 初始化为适当的值
            int         expected    = 0;                 // TODO: 初始化为适当的值
            int         actual;

            actual = target.CompareTo(otherObject);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
 public void CompareToTest()
 {
     ComponentId target = new ComponentId(); // TODO: 初始化为适当的值
     object otherObject = null; // TODO: 初始化为适当的值
     int expected = 0; // TODO: 初始化为适当的值
     int actual;
     actual = target.CompareTo( otherObject );
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }