public void TestValidate() { // Test success _opNode.AddChildNode(new SupportExprNode(typeof(String))); _opNode.AddChildNode(new SupportExprNode(typeof(String))); _opNode.Validate(SupportExprValidationContextFactory.MakeEmpty(_container)); _opNode.SetChildNodes(new SupportExprNode(typeof(String))); // Test too few nodes under this node try { _opNode.Validate(SupportExprValidationContextFactory.MakeEmpty(_container)); Assert.Fail(); } catch (IllegalStateException) { // Expected } // Test mismatch type _opNode.AddChildNode(new SupportExprNode(typeof(int))); try { _opNode.Validate(SupportExprValidationContextFactory.MakeEmpty(_container)); Assert.Fail(); } catch (ExprValidationException) { // Expected } // As of 5.2, booleans are valid because they implement the IComparable interface #if false // Test type cannot be compared _opNode.ChildNodes = new ExprNode[] { new SupportExprNode(typeof(bool?)) }; _opNode.AddChildNode(new SupportExprNode(typeof(bool?))); try { _opNode.Validate(ExprValidationContextFactory.MakeEmpty()); Assert.Fail(); } catch (ExprValidationException ex) { // Expected } #endif }
public static IList <SelectClauseExprRawSpec> MakeAggregateSelectListNoProps() { /* * top (*) * c1 (sum) c2 (10) * c1_1 (5) */ ExprNode top = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false); ExprNode c1 = new ExprSumNode(false); ExprNode c1_1 = new SupportExprNode(5); ExprNode c2 = new SupportExprNode(10); top.AddChildNode(c1); top.AddChildNode(c2); c1.AddChildNode(c1_1); ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.SELECT, top, ExprValidationContextFactory.MakeEmpty()); IList <SelectClauseExprRawSpec> selectionList = new List <SelectClauseExprRawSpec>(); selectionList.Add(new SelectClauseExprRawSpec(top, null, false)); return(selectionList); }
public static void Validate(ExprNode node) { node.Validate(ExprValidationContextFactory.MakeEmpty()); }