public void Constrain_GivenNullConstraint_ThrowsArgumentException()
        {
            var rule = PropertyRule.CreatePropertyRule<Customer, string> ( c => c.FirstName, "Rule1" );
            var ruleBuilder = new PropertyRuleBuilder<RuleEngineContext<Customer>, Customer, string> ( rule );

            ruleBuilder.Constrain ( null );
        }
Exemple #2
0
        public void Constrain_GivenNullConstraint_ThrowsArgumentException()
        {
            var rule        = PropertyRule.CreatePropertyRule <Customer, string> (c => c.FirstName, "Rule1");
            var ruleBuilder = new PropertyRuleBuilder <RuleEngineContext <Customer>, Customer, string> (rule);

            ruleBuilder.Constrain(null);
        }
        public void Constrain_WithAConstraint_AssignsConstraintToRule()
        {
            var rule = PropertyRule.CreatePropertyRule<Customer, string> ( c => c.FirstName, "Rule1" );
            var ruleBuilder = new PropertyRuleBuilder<RuleEngineContext<Customer>, Customer, string> ( rule );

            ruleBuilder.Constrain ( new NotNullConstraint () );

            var customer = new Customer { Age = 10 };
            var context = new RuleEngineContext<Customer> ( customer );

            var whenResult = rule.WhenClause ( context );

            Assert.IsFalse ( whenResult );
        }
Exemple #4
0
        public void Constrain_WithAConstraint_AssignsConstraintToRule()
        {
            var rule        = PropertyRule.CreatePropertyRule <Customer, string> (c => c.FirstName, "Rule1");
            var ruleBuilder = new PropertyRuleBuilder <RuleEngineContext <Customer>, Customer, string> (rule);

            ruleBuilder.Constrain(new NotNullConstraint());

            var customer = new Customer {
                Age = 10
            };
            var context = new RuleEngineContext <Customer> (customer);

            var whenResult = rule.WhenClause(context);

            Assert.IsFalse(whenResult);
        }