Esempio n. 1
0
        /// <summary>
        /// Sets Specification used to validate this Property to the Default
        /// </summary>
        /// <returns><see cref="IAndOr&lt;T, TProperty&gt;"/></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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets Specification used to validate this Property to the Default
        /// </summary>
        /// <returns><see cref="IAndOr&lt;T, TProperty&gt;"/></returns>
        public IAndOr <T, TProperty> Specification <TSpecType>() where TSpecType : Validates <TProperty>, new()
        {
            var specRule = new SpecificationRule <T, TProperty, TSpecType>();

            return(AddRuleAndReturnActionJoin(specRule));
        }
Esempio n. 4
0
        /// <summary>
        /// Sets Specification used to validate this Property to the Default
        /// </summary>
        /// <returns><see cref="IAndOr&lt;T, TProperty&gt;"/></returns>
        public IAndOr <T, TProperty> Specification()
        {
            var specRule = new SpecificationRule <T, TProperty>();

            return(AddRuleAndReturnActionJoin(specRule));
        }
Esempio n. 5
0
        public void CreateSpecificationRule_WithSpecification_ReturnsSpecificationRule()
        {
            var rule = SpecificationRule.CreateSpecificationRule(new TestSpecification(), "Rule 1");

            Assert.IsInstanceOfType(rule, typeof(SpecificationRule));
        }
Esempio n. 6
0
 public void CreateSpecificationRule_WithNullName_ThrowsArgumentException()
 {
     SpecificationRule.CreateSpecificationRule(new TestSpecification(), null);
 }
Esempio n. 7
0
 public void CreateSpecificationRule_WithNullSpecification_ThrowsArgumentException()
 {
     SpecificationRule.CreateSpecificationRule <Customer> (null, "Rule 1");
 }