Divide() public static méthode

public static Divide ( SqlExpression left, SqlExpression right ) : SqlBinaryExpression
left SqlExpression
right SqlExpression
Résultat SqlBinaryExpression
Exemple #1
0
        public void NumericDivide()
        {
            var exp1   = SqlExpression.Constant(Field.Number(new SqlNumber(49021.022)));
            var exp2   = SqlExpression.Constant(Field.Number(new SqlNumber(78.34)));
            var divExp = SqlExpression.Divide(exp1, exp2);

            SqlExpression resultExp = null;

            Assert.DoesNotThrow(() => resultExp = divExp.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).Round(5);
            var expected = new SqlNumber(625.74702, 5);

            Assert.AreEqual(expected, actual);
        }