Or() public static méthode

public static Or ( SqlExpression left, SqlExpression right ) : SqlBinaryExpression
left SqlExpression
right SqlExpression
Résultat SqlBinaryExpression
Exemple #1
0
        public void BooleanOr(bool a, bool b, bool expected)
        {
            var exp1  = SqlExpression.Constant(Field.Boolean(new SqlBoolean(a)));
            var exp2  = SqlExpression.Constant(Field.Boolean(new SqlBoolean(b)));
            var orExp = SqlExpression.Or(exp1, exp2);

            SqlExpression resultExp = null;

            Assert.DoesNotThrow(() => resultExp = orExp.Evaluate());
            Assert.IsNotNull(resultExp);
            Assert.IsInstanceOf <SqlConstantExpression>(resultExp);

            var constExp = (SqlConstantExpression)resultExp;

            Assert.IsNotNull(constExp.Value.Value);
            Assert.IsInstanceOf <BooleanType>(constExp.Value.Type);
            Assert.IsInstanceOf <SqlBoolean>(constExp.Value.Value);

            var actual         = ((SqlBoolean)constExp.Value.Value);
            var expectedResult = new SqlBoolean(expected);

            Assert.AreEqual(expectedResult, actual);
        }
Exemple #2
0
        public void NumericOr(long a, long b, long expected)
        {
            var exp1  = SqlExpression.Constant(Field.Number(new SqlNumber(a)));
            var exp2  = SqlExpression.Constant(Field.Number(new SqlNumber(b)));
            var orExp = SqlExpression.Or(exp1, exp2);

            SqlExpression resultExp = null;

            Assert.DoesNotThrow(() => resultExp = orExp.Evaluate());
            Assert.IsNotNull(resultExp);
            Assert.IsInstanceOf <SqlConstantExpression>(resultExp);

            var constExp = (SqlConstantExpression)resultExp;

            Assert.IsNotNull(constExp.Value.Value);
            Assert.IsInstanceOf <NumericType>(constExp.Value.Type);
            Assert.IsInstanceOf <SqlNumber>(constExp.Value.Value);

            var actual         = ((SqlNumber)constExp.Value.Value);
            var expectedResult = new SqlNumber(expected);

            Assert.AreEqual(expectedResult, actual);
        }