Esempio n. 1
0
        private ExprMathNode MakeNode(Object valueLeft, Type typeLeft, Object valueRight, Type typeRight)
        {
            ExprMathNode mathNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false);

            mathNode.AddChildNode(new SupportExprNode(valueLeft, typeLeft));
            mathNode.AddChildNode(new SupportExprNode(valueRight, typeRight));
            SupportExprNodeUtil.Validate(mathNode);
            return(mathNode);
        }
Esempio n. 2
0
        public void TestToExpressionString()
        {
            // Build sum(4-2)
            var arithNodeChild = new ExprMathNode(MathArithTypeEnum.SUBTRACT, false, false);

            arithNodeChild.AddChildNode(new SupportExprNode(4));
            arithNodeChild.AddChildNode(new SupportExprNode(2));

            _sumNode = new ExprSumNode(false);
            _sumNode.AddChildNode(arithNodeChild);

            Assert.AreEqual("sum(4-2)", _sumNode.ToExpressionStringMinPrecedenceSafe());
        }
Esempio n. 3
0
        public void TestToExpressionString()
        {
            // Build (5*(4-2)), not the same as 5*4-2
            ExprMathNode arithNodeChild = new ExprMathNode(MathArithTypeEnum.SUBTRACT, false, false);

            arithNodeChild.AddChildNode(new SupportExprNode(4));
            arithNodeChild.AddChildNode(new SupportExprNode(2));

            _arithNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false);
            _arithNode.AddChildNode(new SupportExprNode(5));
            _arithNode.AddChildNode(arithNodeChild);

            Assert.AreEqual("5*(4-2)", _arithNode.ToExpressionStringMinPrecedenceSafe());
        }
Esempio n. 4
0
        public void TestEvaluate()
        {
            _arithNode.AddChildNode(new SupportExprNode(10));
            _arithNode.AddChildNode(new SupportExprNode(1.5));
            ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.SELECT, _arithNode, SupportExprValidationContextFactory.MakeEmpty(_container));
            Assert.AreEqual(11.5d, _arithNode.Evaluate(new EvaluateParams(null, false, null)));

            _arithNode = MakeNode(null, typeof(int), 5d, typeof(double?));
            Assert.IsNull(_arithNode.Evaluate(new EvaluateParams(null, false, null)));

            _arithNode = MakeNode(5, typeof(int), null, typeof(double?));
            Assert.IsNull(_arithNode.Evaluate(new EvaluateParams(null, false, null)));

            _arithNode = MakeNode(null, typeof(int), null, typeof(double?));
            Assert.IsNull(_arithNode.Evaluate(new EvaluateParams(null, false, null)));
        }
Esempio n. 5
0
 public void SetUp()
 {
     _container = SupportContainer.Reset();
     _arithNode = new ExprMathNode(MathArithTypeEnum.ADD, false, false);
 }