Example #1
0
        private ExprMathNode MakeNode(
            object valueLeft,
            Type typeLeft,
            object valueRight,
            Type typeRight)
        {
            var mathNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false);

            mathNode.AddChildNode(new SupportExprNode(valueLeft, typeLeft));
            mathNode.AddChildNode(new SupportExprNode(valueRight, typeRight));
            SupportExprNodeUtil.Validate(container, mathNode);
            return(mathNode);
        }
Example #2
0
        public void TestToExpressionString()
        {
            // Build (5*(4-2)), not the same as 5*4-2
            var 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)", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(arithNode));
        }
Example #3
0
        public void TestEvaluate()
        {
            arithNode.AddChildNode(new SupportExprNode(10));
            arithNode.AddChildNode(new SupportExprNode(1.5));
            ExprNodeUtilityValidate.GetValidatedSubtree(ExprNodeOrigin.SELECT, arithNode, SupportExprValidationContextFactory.MakeEmpty(container));
            Assert.AreEqual(11.5d, arithNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            arithNode = MakeNode(null, typeof(int?), 5d, typeof(double?));
            Assert.IsNull(arithNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            arithNode = MakeNode(5, typeof(int?), null, typeof(double?));
            Assert.IsNull(arithNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            arithNode = MakeNode(null, typeof(int?), null, typeof(double?));
            Assert.IsNull(arithNode.Forge.ExprEvaluator.Evaluate(null, false, null));
        }