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)); }
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"); }
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)); }
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"); }
/// <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)); }
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; }
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, ">="); }
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, ">="); }
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, ">="); }
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)); }
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); }
//-----------// // 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)); }
public bool Equals(EquatableTriple <T1, T2, T3> other) { return(First.Equals(other.First) && Second.Equals(other.Second) && Third.Equals(other.Third)); }
public bool Equals(LoosePair <T, U> other) { return((First.Equals(other.First) || First.Equals(other.Second)) && (Second.Equals(other.First) || Second.Equals(other.Second))); }
public bool Equals(Pair <TFirst, TSecond> other) { return(First.Equals(other.First) && Second.Equals(other.Second)); }
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)))); }