Ejemplo n.º 1
0
        public void When()
        {
            Expression <Func <Customer, bool> >             expression  = x => x.Age.HasValue;
            IEntityValidationRuleBuilder <Customer, string> ruleBuilder = Substitute.For <IEntityValidationRuleBuilder <Customer, string> >();

            ruleBuilder.WhenForAnyArgs(x => x.SetSpecification(null)).Do(x => Assert.AreEqual(expression, x.Arg <ISpecification <Customer> >().Predicate));

            EntityPropertyValidationRuleExtensions.When(ruleBuilder, expression);

            ruleBuilder.ReceivedWithAnyArgs(1).SetSpecification(null);
        }
Ejemplo n.º 2
0
 public void WhenMustThrowArgumentNullExceptionWhenPredicateIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.When(Substitute.For <IEntityValidationRuleBuilder <Customer, string> >(), null));
 }
Ejemplo n.º 3
0
 public void WhenMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.When <Customer, string>(null, x => x.Age != null));
 }