Ejemplo n.º 1
0
        public bool CreateExpression_GroupNodeContainingSingleRuleNode_BuildsExpression(bool propertyValue)
        {
            var tree = new RuleTree.RuleTree <Contact, bool>(
                new GroupNode(new RuleTree.RuleNode(new IsTrue <Contact>())));

            Assert.That(tree.LambdaExpression, Is.Not.Null);

            RuleValidatorContext <Contact, bool> context = BuildContextForContactActive(propertyValue);

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            var isValid = tree.LambdaExpression(context, null, notification);

            return(isValid);
        }
Ejemplo n.º 2
0
        public void CreateExpression_TwoRules_OrRelation_BuildsExpression(int year, int month, int day, bool validates, int numberOfErrorMsg)
        {
            var floorDate   = new DateTime(2010, 2, 1);
            var ceilingDate = new DateTime(2010, 3, 1);
            var testDate    = new DateTime(year, month, day);

            var tree = new RuleTree.RuleTree <CalendarEvent, DateTime>(
                new RuleTree.RuleNode(new LessThan <CalendarEvent, DateTime>(floorDate)));

            tree.Root.OrChild(new RuleNode(new GreaterThan <CalendarEvent, DateTime>(ceilingDate)));

            Assert.That(tree.LambdaExpression, Is.Not.Null);

            var context      = BuildContextForCalendarEventStartDate(testDate);
            var notification = new ValidationNotification();
            var isValid      = tree.LambdaExpression(context, null, notification);

            Assert.That(isValid, Is.EqualTo(validates));
        }
Ejemplo n.º 3
0
        public void CreateExpression_TwoRules_OrRelation_BuildsExpression(int year, int month, int day, bool validates, int numberOfErrorMsg)
        {
            var floorDate = new DateTime(2010, 2, 1);
            var ceilingDate = new DateTime(2010, 3, 1);
            var testDate = new DateTime(year, month, day);

            var tree = new RuleTree.RuleTree<CalendarEvent, DateTime>(
                new RuleTree.RuleNode(new LessThan<CalendarEvent, DateTime>(floorDate)));

            tree.Root.OrChild(new RuleNode(new GreaterThan<CalendarEvent, DateTime>(ceilingDate)));

            Assert.That(tree.LambdaExpression, Is.Not.Null);

            var context = BuildContextForCalendarEventStartDate(testDate);
            var notification = new ValidationNotification();
            var isValid = tree.LambdaExpression(context, null, notification);

            Assert.That(isValid, Is.EqualTo(validates));
        }
Ejemplo n.º 4
0
        public bool CreateExpression_SingleRule_BuildsExpression(bool propertyValue)
        {
            var tree = new RuleTree.RuleTree<Contact, bool>(
                new RuleTree.RuleNode(new IsTrue<Contact>()));

            Assert.That(tree.LambdaExpression, Is.Not.Null);

            RuleValidatorContext<Contact, bool> context = BuildContextForContactActive(propertyValue);

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            var isValid = tree.LambdaExpression(context, null, notification);

            return isValid;
        }