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 ); }
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 ); }
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); }
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); }