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