public void GetTypeEqualityFunction_CustomTypeWithStaticEqualsMethod_ReturnsFunctionWhichCallsEqualsFunction() { bool returnValue = Random.NextDouble() < 0.5; TestTypeWithStaticEquals testObject = new TestTypeWithStaticEquals(returnValue); Func <object, object, bool> equalityFunction = typeof(TestTypeWithStaticEquals).GetTypeEqualityFunction(); Assert.AreEqual( returnValue, equalityFunction(testObject, testObject), "The function returned by GetTypeEqualityFunction should call the most appropriate custom Equals method for a custom type."); Assert.IsTrue( TestTypeWithStaticEquals.EqualsCalled, "The function returned by GetTypeEqualityFunction should call the most appropriate custom Equals method for a custom type."); }
public void GetTypeEqualityFunction_CustomTypeWithStaticEqualsMethod_ReturnsFunctionWhichCallsEqualsFunction() { bool returnValue = Random.NextDouble() < 0.5; TestTypeWithStaticEquals testObject = new TestTypeWithStaticEquals(returnValue); Func<object, object, bool> equalityFunction = typeof (TestTypeWithStaticEquals).GetTypeEqualityFunction(); Assert.AreEqual( returnValue, equalityFunction(testObject, testObject), "The function returned by GetTypeEqualityFunction should call the most appropriate custom Equals method for a custom type."); Assert.IsTrue( TestTypeWithStaticEquals.EqualsCalled, "The function returned by GetTypeEqualityFunction should call the most appropriate custom Equals method for a custom type."); }
public static bool Equals(TestTypeWithStaticEquals first, TestTypeWithStaticEquals second) { EqualsCalled = true; return(ReturnValue); }
public static bool Equals(TestTypeWithStaticEquals first, TestTypeWithStaticEquals second) { EqualsCalled = true; return ReturnValue; }