Пример #1
0
        public void ShouldntTriggerOnOperatorEquals()
        {
            var hint = new EnumerableEqualsHint();

            var x = new[] { 3 };
            var y = new[] { 3 };

            Expression <Func <bool> > assertion = () => x == y;
            var p = new ExpressionParser(assertion.Body);

            string message;

            Assert.IsFalse(hint.TryGetHint(p, assertion.Body, out message));
            Assert.IsNull(message);
        }
Пример #2
0
        public void DoesntExplodeIfOneIsNull()
        {
            var hint = new EnumerableEqualsHint();

            var    x = new[] { 3 };
            object y = null;

            Expression <Func <bool> > assertion = () => x.Equals(y);
            var p = new ExpressionParser(assertion.Body);

            string message;

            Assert.IsFalse(hint.TryGetHint(p, assertion.Body, out message));
            Assert.IsNull(message);
        }
Пример #3
0
        public void ShouldTriggerOnSequenceEqualEnumerables()
        {
            var hint = new EnumerableEqualsHint();

            var x = new[] { 3 };
            var y = new[] { 3 };

            Expression <Func <bool> > assertion = () => x.Equals(y);
            var p = new ExpressionParser(assertion.Body);

            string message;

            Assert.IsTrue(hint.TryGetHint(p, assertion.Body, out message));
            Assert.IsNotNull(message);
        }
Пример #4
0
        public void ShouldntTriggerForRandomMethodCalledEqualsEvenIfItSequenceEquals()
        {
            var hint = new EnumerableEqualsHint();

            var x = new StupidClass();
            var y = new[] { 3 };

            Expression <Func <bool> > assertion = () => x.Equals(y);
            var p = new ExpressionParser(assertion.Body);

            string message;

            Assert.IsFalse(hint.TryGetHint(p, assertion.Body, out message));
            Assert.IsNull(message);
        }