Пример #1
0
        public void ArrayExpressionHasHashCode()
        {
            var a = new ArrayExpression(1, 2, 3);
            var b = new ArrayExpression(1, 2, 3);
            var c = new ArrayExpression(4, 5, 6);

            Assert.IsNotNull(a);
            Assert.IsNotNull(b);
            Assert.IsNotNull(c);
            Assert.IsTrue(Equals(a.GetHashCode(), b.GetHashCode()));
            Assert.IsFalse(Equals(a.GetHashCode(), c.GetHashCode()));
        }
        public void ArrayExpressionHasHashCode()
        {
            var a = new ArrayExpression(1, 2, 3);
            var b = new ArrayExpression(1, 2, 3);
            var c = new ArrayExpression(4, 5, 6);

            Assert.IsNotNull(a);
            Assert.IsNotNull(b);
            Assert.IsNotNull(c);
            Assert.IsTrue(Equals(a.GetHashCode(), b.GetHashCode()));
            Assert.IsFalse(Equals(a.GetHashCode(), c.GetHashCode()));
        }
Пример #3
0
        public void Equals()
        {
            ArrayExpression expr1 = new ArrayExpression(new IExpression[] { new ConstantExpression(1), new ConstantExpression(2) });
            ArrayExpression expr2 = new ArrayExpression(new IExpression[] { new ConstantExpression(1), new ConstantExpression(2), new ConstantExpression(3) });
            ArrayExpression expr3 = new ArrayExpression(new IExpression[] { new ConstantExpression(1), new ConstantExpression(3) });
            ArrayExpression expr4 = new ArrayExpression(new IExpression[] { });
            ArrayExpression expr5 = new ArrayExpression(new IExpression[] { new ConstantExpression(1), new ConstantExpression(2) });

            Assert.IsTrue(expr1.Equals(expr5));
            Assert.IsTrue(expr5.Equals(expr1));
            Assert.AreEqual(expr1.GetHashCode(), expr5.GetHashCode());

            Assert.IsFalse(expr1.Equals(null));
            Assert.IsFalse(expr1.Equals(123));
            Assert.IsFalse(expr1.Equals(expr2));
            Assert.IsFalse(expr2.Equals(expr1));
            Assert.IsFalse(expr1.Equals(expr3));
            Assert.IsFalse(expr3.Equals(expr1));
            Assert.IsFalse(expr1.Equals(expr4));
            Assert.IsFalse(expr4.Equals(expr1));
        }