public void TestGetValidatedSubtree() { SupportExprNode.SetValidateCount(0); // Confirms all child nodes validated // Confirms depth-first validation SupportExprNode topNode = new SupportExprNode(typeof(Boolean)); SupportExprNode parent_1 = new SupportExprNode(typeof(Boolean)); SupportExprNode parent_2 = new SupportExprNode(typeof(Boolean)); topNode.AddChildNode(parent_1); topNode.AddChildNode(parent_2); SupportExprNode supportNode1_1 = new SupportExprNode(typeof(Boolean)); SupportExprNode supportNode1_2 = new SupportExprNode(typeof(Boolean)); SupportExprNode supportNode2_1 = new SupportExprNode(typeof(Boolean)); SupportExprNode supportNode2_2 = new SupportExprNode(typeof(Boolean)); parent_1.AddChildNode(supportNode1_1); parent_1.AddChildNode(supportNode1_2); parent_2.AddChildNode(supportNode2_1); parent_2.AddChildNode(supportNode2_2); ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.SELECT, topNode, SupportExprValidationContextFactory.MakeEmpty(_container)); Assert.AreEqual(1, supportNode1_1.ValidateCountSnapshot); Assert.AreEqual(2, supportNode1_2.ValidateCountSnapshot); Assert.AreEqual(3, parent_1.ValidateCountSnapshot); Assert.AreEqual(4, supportNode2_1.ValidateCountSnapshot); Assert.AreEqual(5, supportNode2_2.ValidateCountSnapshot); Assert.AreEqual(6, parent_2.ValidateCountSnapshot); Assert.AreEqual(7, topNode.ValidateCountSnapshot); }
public void TestGetAggregatesBottomUp() { /* * top (ag) * c1 c2 * c1_1 (ag) c1_2 (ag) c2_1 c2_2 * c2_1_1 (ag) c2_1_2 (ag) * */ ExprNode top = new SupportAggregateExprNode(null); ExprNode c1 = new SupportExprNode(null); ExprNode c2 = new SupportExprNode(null); top.AddChildNode(c1); top.AddChildNode(c2); ExprNode c1_1 = new SupportAggregateExprNode(null); ExprNode c1_2 = new SupportAggregateExprNode(null); c1.AddChildNode(c1_1); c1.AddChildNode(c1_2); c1_1.AddChildNode(new SupportExprNode(null)); c1_2.AddChildNode(new SupportExprNode(null)); ExprNode c2_1 = new SupportExprNode(null); ExprNode c2_2 = new SupportExprNode(null); c2.AddChildNode(c2_1); c2.AddChildNode(c2_2); c2_2.AddChildNode(new SupportExprNode(null)); ExprNode c2_1_1 = new SupportAggregateExprNode(null); ExprNode c2_1_2 = new SupportAggregateExprNode(null); c2_1.AddChildNode(c2_1_1); c2_1.AddChildNode(c2_1_2); List <ExprAggregateNode> aggregates = new List <ExprAggregateNode>(); ExprAggregateNodeUtil.GetAggregatesBottomUp(top, aggregates); Assert.AreEqual(5, aggregates.Count); Assert.AreSame(c2_1_1, aggregates[0]); Assert.AreSame(c2_1_2, aggregates[1]); Assert.AreSame(c1_1, aggregates[2]); Assert.AreSame(c1_2, aggregates[3]); Assert.AreSame(top, aggregates[4]); // Test no aggregates aggregates.Clear(); ExprAggregateNodeUtil.GetAggregatesBottomUp(new SupportExprNode(null), aggregates); Assert.IsTrue(aggregates.IsEmpty()); }