示例#1
0
 public ExprMathNodeForge(
     ExprMathNode parent,
     MathArithType.Computer arithTypeEnumComputer,
     Type resultType)
 {
     ForgeRenderable = parent;
     ArithTypeEnumComputer = arithTypeEnumComputer;
     EvaluationType = resultType;
 }
示例#2
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);
        }
示例#3
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));
        }
示例#4
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));
        }
示例#5
0
 public void SetUp()
 {
     arithNode = new ExprMathNode(MathArithTypeEnum.ADD, false, false);
 }