Пример #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);
        }
Пример #2
0
 public void BetweenForNullablePropertyMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.Between((IEntityValidationRuleBuilderInitial <Customer, int?>)null, 1, 10));
 }
Пример #3
0
 public void GreaterThanOrEqualToForNullablePropertyMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.GreaterThanOrEqualTo((IEntityValidationRuleBuilderInitial <Customer, int?>)null, 1));
 }
Пример #4
0
 public void PhoneNumberThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.PhoneNumber((IEntityValidationRuleBuilderInitial <Customer, string>)null));
 }
Пример #5
0
 public void LessThanOrEqualToMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.LessThanOrEqualTo((IEntityValidationRuleBuilderInitial <Customer, int>)null, 1));
 }
Пример #6
0
 public void UnlessMustThrowArgumentNullExceptionWhenPredicateIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.Unless(Substitute.For <IEntityValidationRuleBuilder <Customer, string> >(), null));
 }
Пример #7
0
 public void UnlessMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.Unless <Customer, string>(null, x => x.Age != null));
 }
Пример #8
0
 public void CreditCardMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.CreditCard <Customer>(null));
 }
Пример #9
0
 public void BetweenMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.Between((IEntityValidationRuleBuilderInitial <Customer, string>)null, "1", "2"));
 }
Пример #10
0
 public void NotEqualToMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.NotEqualTo <Customer, string>(null, string.Empty, StringComparer.OrdinalIgnoreCase));
 }
Пример #11
0
 public void EmailAddressMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.EmailAddress <Customer>(null));
 }
Пример #12
0
 public void MatchesMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.Matches <Customer>(null, string.Empty, RegexOptions.Compiled));
 }
Пример #13
0
 public void ExactLengthMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.Length <Customer>(null, 10));
 }
Пример #14
0
 public void NotEmptyMustThrowArgumentNullExceptionWhenRuleBuilderIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.NotEmpty <Customer, string>(null));
 }