コード例 #1
0
ファイル: RuleBuilder.cs プロジェクト: ne4ta/SpecExpress
        /// <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));
        }
コード例 #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);
        }
コード例 #3
0
ファイル: RuleBuilder.cs プロジェクト: ne4ta/SpecExpress
        /// <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));
        }
コード例 #4
0
ファイル: RuleBuilder.cs プロジェクト: ne4ta/SpecExpress
        /// <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));
        }
コード例 #5
0
        public void CreateSpecificationRule_WithSpecification_ReturnsSpecificationRule()
        {
            var rule = SpecificationRule.CreateSpecificationRule(new TestSpecification(), "Rule 1");

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