public void TriggersOnSameObjectForMethodEquals() { var hint = new BrokenEqualityHint(); var x = new object(); Expression <Func <bool> > exp = () => x.Equals(x); var p = new ExpressionParser(exp.Body); string ignored; Assert.IsTrue(hint.TryGetHint(p, exp.Body, out ignored)); Assert.IsNotNull(ignored); }
public void PicksUpCorrectTypeForOverriddenMethodEquals() { var hint = new BrokenEqualityHint(); var x = new OverridesEqualsBadly(); Expression <Func <bool> > exp = () => x.Equals(x); var p = new ExpressionParser(exp.Body); string ignored; Assert.IsTrue(hint.TryGetHint(p, exp.Body, out ignored)); Assert.IsNotNull(ignored); Assert.IsTrue(ignored.Contains(x.GetType().Name)); }
public void DoesntTriggerWithDifferingObjectsForOperatorEquals() { var hint = new BrokenEqualityHint(); var x = new object(); var y = new object(); Expression <Func <bool> > exp = () => x == y; var p = new ExpressionParser(exp.Body); string ignored; Assert.IsFalse(hint.TryGetHint(p, exp.Body, out ignored)); Assert.IsNull(ignored); }