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