Esempio n. 1
0
        public void TestValidate()
        {
            // test success
            orNode.AddChildNode(new SupportExprNode(typeof(bool?)));
            orNode.AddChildNode(new SupportExprNode(typeof(bool?)));
            orNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));

            // test failure, type mismatch
            orNode.AddChildNode(new SupportExprNode(typeof(string)));
            try
            {
                orNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }

            // test failed - with just one child
            orNode = new ExprOrNode();
            orNode.AddChildNode(new SupportExprNode(typeof(bool?)));
            try
            {
                orNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }
        }
Esempio n. 2
0
        public void TestEvaluate()
        {
            orNode.AddChildNode(new SupportBoolExprNode(true));
            orNode.AddChildNode(new SupportBoolExprNode(false));
            SupportExprNodeUtil.Validate(container, orNode);
            Assert.IsTrue((bool)orNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            orNode = new ExprOrNode();
            orNode.AddChildNode(new SupportBoolExprNode(false));
            orNode.AddChildNode(new SupportBoolExprNode(false));
            SupportExprNodeUtil.Validate(container, orNode);
            Assert.IsFalse((bool)orNode.Forge.ExprEvaluator.Evaluate(null, false, null));

            orNode = new ExprOrNode();
            orNode.AddChildNode(new SupportExprNode(null, typeof(bool?)));
            orNode.AddChildNode(new SupportExprNode(false));
            SupportExprNodeUtil.Validate(container, orNode);
            Assert.IsNull(orNode.Forge.ExprEvaluator.Evaluate(null, false, null));
        }