public void SecondEqualsReturnsFalseIfOtherIsNotTypeOfSecond()
        {
            Second second = new Second(47);
            Task   other  = new Task(() => { });

            Assert.IsFalse(second.Equals(other));
        }
        public void SecondEqualsReturnsTrueIfOtherIsSameValue()
        {
            Second second = new Second(47);
            Second other  = new Second(47);

            Assert.IsTrue(second.Equals(other));
        }
        public void SecondEqualsReturnsFalseIfOtherIsDifferentValue()
        {
            Second second = new Second(47);
            Second other  = new Second(45);

            Assert.IsFalse(second.Equals(other));
        }
示例#4
0
        public void Should_compare_with_null_instance(double value)
        {
            var instance = new Second(value);

            Assert.IsFalse(instance.Equals(null), "Equals");
            Assert.AreEqual(1, instance.CompareTo(null), "CompareTo");
        }
示例#5
0
        public bool equals(Object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is Triple <T1, T2, T3>))
            {
                return(false);
            }

            Triple <T1, T2, T3> triple = (Triple <T1, T2, T3>)o;

            if (First != null ? !First.Equals(triple.First) : triple.First != null)
            {
                return(false);
            }
            if (Second != null ? !Second.Equals(triple.Second) : triple.Second != null)
            {
                return(false);
            }
            if (Third != null ? !Third.Equals(triple.Third) : triple.Third != null)
            {
                return(false);
            }

            return(true);
        }
        public void SecondEqualsReturnsFalseIfOtherIsNull()
        {
            Second second = new Second(47);
            Second other  = null;

            Assert.IsFalse(second.Equals(other));
        }
示例#7
0
        public void Should_compare_with_another_type_of_instance(double value)
        {
            var    instance1 = new Second(value);
            object instance2 = value;

            Assert.IsFalse(instance1.Equals(instance2), "Equals");
            Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo");
        }
示例#8
0
        /// <summary>
        /// 是否相等
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (!(obj is Triple <T>))
            {
                return(false);
            }
            var o = obj as Triple <T>;

            return(First.Equals(o.First) && Second.Equals(o.Second) && Third.Equals(o.Third));
        }
示例#9
0
 public override bool Equals(Object o)
 {
     if (o is Triplet<X, Y, Z>)
     {
         Triplet<X, Y, Z> other = (Triplet<X, Y, Z>)o;
         return (First.Equals(other.First)) && (Second.Equals(other.Second))
                 && (Third.Equals(other.Third));
     }
     return false;
 }
示例#10
0
        public void Should_compare_with_bigger_value(double baseValue, double biggerValue)
        {
            var baseInstance   = new Second(baseValue);
            var biggerInstance = new Second(biggerValue);

            Assert.IsFalse(baseInstance.Equals(biggerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)biggerInstance), "Equals object");

            Assert.IsFalse(baseInstance == biggerInstance, "==");
            Assert.IsTrue(baseInstance != biggerInstance, "!=");

            Assert.AreEqual(-1, baseInstance.CompareTo(biggerInstance), "CompareTo");
            Assert.AreEqual(-1, baseInstance.CompareTo((object)biggerInstance), "CompareTo object");

            Assert.IsTrue(baseInstance < biggerInstance, "<");
            Assert.IsFalse(baseInstance > biggerInstance, ">");

            Assert.IsTrue(baseInstance <= biggerInstance, "<=");
            Assert.IsFalse(baseInstance >= biggerInstance, ">=");
        }
示例#11
0
        public void Should_compare_with_smaller_value(double baseValue, double smallerValue)
        {
            var baseInstance    = new Second(baseValue);
            var smallerInstance = new Second(smallerValue);

            Assert.IsFalse(baseInstance.Equals(smallerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)smallerInstance), "Equals object");

            Assert.IsFalse(baseInstance == smallerInstance, "==");
            Assert.IsTrue(baseInstance != smallerInstance, "!=");

            Assert.AreEqual(+1, baseInstance.CompareTo(smallerInstance), "CompareTo");
            Assert.AreEqual(+1, baseInstance.CompareTo((object)smallerInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < smallerInstance, "<");
            Assert.IsTrue(baseInstance > smallerInstance, ">");

            Assert.IsFalse(baseInstance <= smallerInstance, "<=");
            Assert.IsTrue(baseInstance >= smallerInstance, ">=");
        }
示例#12
0
        public void Should_compare_with_same_value(double value)
        {
            var baseInstance  = new Second(value);
            var otherInstance = new Second(value);

            Assert.IsTrue(baseInstance.Equals(otherInstance), "Equals");
            Assert.IsTrue(baseInstance.Equals((object)otherInstance), "Equals object");

            Assert.IsTrue(baseInstance == otherInstance, "==");
            Assert.IsFalse(baseInstance != otherInstance, "!=");

            Assert.AreEqual(0, baseInstance.CompareTo(otherInstance), "CompareTo");
            Assert.AreEqual(0, baseInstance.CompareTo((object)otherInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < otherInstance, "<");
            Assert.IsFalse(baseInstance > otherInstance, ">");

            Assert.IsTrue(baseInstance <= otherInstance, "<=");
            Assert.IsTrue(baseInstance >= otherInstance, ">=");
        }
示例#13
0
        public override bool Equals(object obj)
        {
            if (obj is Tuple3 <TFirst, TSecond, TThree> )
            {
                var other = (Tuple3 <TFirst, TSecond, TThree>)obj;

                return(First.Equals(other.First) && Second.Equals(other.Second) && Three.Equals(other.Three));
            }

            return(base.Equals(obj));
        }
示例#14
0
        public override bool Equals(object obj)
        {
            if (obj is UnorderedPair <FirstType, SecondType> )
            {
                Pair <FirstType, SecondType> pair = (Pair <FirstType, SecondType>)obj;
                return((First.Equals(pair.First) && Second.Equals(pair.Second)) ||
                       (First.Equals(pair.Second) && Second.Equals(pair.First)));
            }

            return(false);
        }
示例#15
0
    //-----------//
    // Overrides //
    //-----------//
    public override bool Equals(object obj)
    {
        // Check null
        if (obj == null)
        {
            return(false);
        }

        // Check type
        Tuple <T, U> objAsTuple = obj as Tuple <T, U>;

        if (objAsTuple == null)
        {
            return(false);
        }

        return(First.Equals(objAsTuple.First) && Second.Equals(objAsTuple.Second));
    }
 /// <summary>
 /// Equals operator
 /// </summary>
 /// <param name="First">First item</param>
 /// <param name="Second">Second item</param>
 /// <returns>True if they are, false otherwise</returns>
 public static bool operator ==(double First, Fraction Second)
 {
     return(Second.Equals(First));
 }
示例#17
0
 public bool Equals(EquatableTriple <T1, T2, T3> other)
 {
     return(First.Equals(other.First) && Second.Equals(other.Second) && Third.Equals(other.Third));
 }
示例#18
0
 public bool Equals(LoosePair <T, U> other)
 {
     return((First.Equals(other.First) || First.Equals(other.Second)) &&
            (Second.Equals(other.First) || Second.Equals(other.Second)));
 }
示例#19
0
 public bool Equals(Pair <TFirst, TSecond> other)
 {
     return(First.Equals(other.First) && Second.Equals(other.Second));
 }
示例#20
0
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        if (obj == this)
        {
            return(true);
        }

        Triplet <F, S, T> other = obj as Triplet <F, S, T>;

        if (other == null)
        {
            return(false);
        }

        return((((this.First == null) && (other.First == null)) || ((this.First != null) && First.Equals(other.First))) &&
               (((this.Second == null) && (other.Second == null)) || ((this.Second != null) && Second.Equals(other.Second))) &&
               (((this.Third == null) && (other.Third == null)) || ((this.Third != null) && Third.Equals(other.Third))));
    }