Beispiel #1
0
        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 TestEvaluate()
        {
            SupportExprNode childOne = new SupportExprNode("d");
            SupportExprNode childTwo = new SupportExprNode("c");

            _opNode.AddChildNode(childOne);
            _opNode.AddChildNode(childTwo);
            _opNode.Validate(ExprValidationContextFactory.MakeEmpty());       // Type initialization

            var eparams = new EvaluateParams(null, false, null);

            Assert.AreEqual(true, _opNode.Evaluate(eparams));

            childOne.Value = "c";
            Assert.AreEqual(true, _opNode.Evaluate(eparams));

            childOne.Value = "b";
            Assert.AreEqual(false, _opNode.Evaluate(eparams));

            _opNode = MakeNode(null, typeof(int), 2, typeof(int));
            Assert.AreEqual(null, _opNode.Evaluate(eparams));
            _opNode = MakeNode(1, typeof(int), null, typeof(int));
            Assert.AreEqual(null, _opNode.Evaluate(eparams));
            _opNode = MakeNode(null, typeof(int), null, typeof(int));
            Assert.AreEqual(null, _opNode.Evaluate(eparams));
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        public void TestEvaluate()
        {
            var childOne = new SupportExprNode("d");
            var childTwo = new SupportExprNode("c");

            opNode.AddChildNode(childOne);
            opNode.AddChildNode(childTwo);
            opNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container)); // Type initialization

            Assert.AreEqual(true, opNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            childOne.Value = "c";
            Assert.AreEqual(true, opNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            childOne.Value = "b";
            Assert.AreEqual(false, opNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            opNode = MakeNode(null, typeof(int?), 2, typeof(int?));
            Assert.AreEqual(null, opNode.Forge.ExprEvaluator.Evaluate(null, false, null));
            opNode = MakeNode(1, typeof(int?), null, typeof(int?));
            Assert.AreEqual(null, opNode.Forge.ExprEvaluator.Evaluate(null, false, null));
            opNode = MakeNode(null, typeof(int?), null, typeof(int?));
            Assert.AreEqual(null, opNode.Forge.ExprEvaluator.Evaluate(null, false, null));
        }