Example #1
0
        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);
        }
Example #2
0
        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));
        }
Example #3
0
        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);
        }