/// <summary> /// Sets Specification used to validate this Property to the Default /// </summary> /// <returns><see cref="IAndOr<T, TProperty>"/></returns> public IAndOr <T, TProperty> Specification(Action <Validates <TProperty> > rules) { var specification = new SpecificationExpression <TProperty>(); rules(specification); var specRule = new SpecificationRule <T, TProperty>(specification); return(AddRuleAndReturnActionJoin(specRule)); }
public void CreateSpecificationRule_WithSpecification_SpecificationIsUsed() { var specification = new TestSpecification(); var rule = SpecificationRule.CreateSpecificationRule(specification, "Rule 1"); var customer = new Customer(); var context = new RuleEngineContext <Customer> (customer); rule.WhenClause(context); Assert.IsTrue(specification.IsSatisfiedByCalled); }
/// <summary> /// Sets Specification used to validate this Property to the Default /// </summary> /// <returns><see cref="IAndOr<T, TProperty>"/></returns> public IAndOr <T, TProperty> Specification <TSpecType>() where TSpecType : Validates <TProperty>, new() { var specRule = new SpecificationRule <T, TProperty, TSpecType>(); return(AddRuleAndReturnActionJoin(specRule)); }
/// <summary> /// Sets Specification used to validate this Property to the Default /// </summary> /// <returns><see cref="IAndOr<T, TProperty>"/></returns> public IAndOr <T, TProperty> Specification() { var specRule = new SpecificationRule <T, TProperty>(); return(AddRuleAndReturnActionJoin(specRule)); }
public void CreateSpecificationRule_WithSpecification_ReturnsSpecificationRule() { var rule = SpecificationRule.CreateSpecificationRule(new TestSpecification(), "Rule 1"); Assert.IsInstanceOfType(rule, typeof(SpecificationRule)); }
public void CreateSpecificationRule_WithNullName_ThrowsArgumentException() { SpecificationRule.CreateSpecificationRule(new TestSpecification(), null); }
public void CreateSpecificationRule_WithNullSpecification_ThrowsArgumentException() { SpecificationRule.CreateSpecificationRule <Customer> (null, "Rule 1"); }