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); }
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)); }
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)); }