예제 #1
0
        public void EqualTo_ValueNotEqualToProperty_RuleFails()
        {
            var rule = PropertyRule.CreatePropertyRule<Customer, int> ( c => c.Age, "Rule 1" );
            var ruleBuilder = new PropertyRuleBuilder<RuleEngineContext<Customer>, Customer, int> ( rule );
            ruleBuilder.GreaterThan ( 15 );

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

            var whenResult = rule.WhenClause ( context );

            Assert.IsFalse ( whenResult );
        }
예제 #2
0
        public void GreaterThan_ValueIsLessThenProperty_RulePasses()
        {
            var rule = PropertyRule.CreatePropertyRule<Customer, int> ( c => c.Age, "Rule 1" );
            var ruleBuilder = new PropertyRuleBuilder<RuleEngineContext<Customer>, Customer, int> ( rule );
            ruleBuilder.GreaterThan ( 5 );

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

            var whenResult = rule.WhenClause ( context );

            Assert.IsTrue ( whenResult );
        }
예제 #3
0
        public void EqualTo_ValueNotEqualToProperty_RuleFails()
        {
            var rule        = PropertyRule.CreatePropertyRule <Customer, int> (c => c.Age, "Rule 1");
            var ruleBuilder = new PropertyRuleBuilder <RuleEngineContext <Customer>, Customer, int> (rule);

            ruleBuilder.GreaterThan(15);

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

            var whenResult = rule.WhenClause(context);

            Assert.IsFalse(whenResult);
        }
예제 #4
0
        public void GreaterThan_ValueIsLessThenProperty_RulePasses()
        {
            var rule        = PropertyRule.CreatePropertyRule <Customer, int> (c => c.Age, "Rule 1");
            var ruleBuilder = new PropertyRuleBuilder <RuleEngineContext <Customer>, Customer, int> (rule);

            ruleBuilder.GreaterThan(5);

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

            var whenResult = rule.WhenClause(context);

            Assert.IsTrue(whenResult);
        }