Exemplo n.º 1
0
        public static void Validate_throws_for_invalid_local_part()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws<ValidationException>(() => attribute.Validate("@someDomain.com", s_testValidationContext)); // no local part
            Assert.Throws<ValidationException>(() => attribute.Validate("@[email protected]", s_testValidationContext)); // multiple @'s
        }
Exemplo n.º 2
0
        public static void Validate_throws_for_invalid_local_part()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate("@someDomain.com", s_testValidationContext));     // no local part
            Assert.Throws <ValidationException>(() => attribute.Validate("@[email protected]", s_testValidationContext)); // multiple @'s
        }
Exemplo n.º 3
0
        public static void Validate_throws_for_invalid_domain_name()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate("someName", s_testValidationContext));         // no domain
            Assert.Throws <ValidationException>(() => attribute.Validate("someName@", s_testValidationContext));        // no domain
            Assert.Throws <ValidationException>(() => attribute.Validate("someName@[email protected]", s_testValidationContext)); // multiple @'s
        }
Exemplo n.º 4
0
        public static void Validate_throws_for_invalid_domain_name()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws<ValidationException>(() => attribute.Validate("someName", s_testValidationContext)); // no domain
            Assert.Throws<ValidationException>(() => attribute.Validate("someName@", s_testValidationContext)); // no domain
            Assert.Throws<ValidationException>(() => attribute.Validate("someName@[email protected]", s_testValidationContext)); // multiple @'s
        }
Exemplo n.º 5
0
        public static void Validate_successful_for_valid_domain_part()
        {
            var attribute = new EmailAddressAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext));       // Simple valid value
            AssertEx.DoesNotThrow(() => attribute.Validate("someName@some~domain.com", s_testValidationContext));      // With tilde
            AssertEx.DoesNotThrow(() => attribute.Validate("someName@some_domain.com", s_testValidationContext));      // With underscore
            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext));             // numbers are valid
            AssertEx.DoesNotThrow(() => attribute.Validate("someName@someDomain\uFFEF.com", s_testValidationContext)); // With valid \u character
        }
Exemplo n.º 6
0
        public static void Validate_successful_for_valid_domain_part()
        {
            var attribute = new EmailAddressAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // Simple valid value
            AssertEx.DoesNotThrow(() => attribute.Validate("someName@some~domain.com", s_testValidationContext)); // With tilde
            AssertEx.DoesNotThrow(() => attribute.Validate("someName@some_domain.com", s_testValidationContext)); // With underscore
            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // numbers are valid
            AssertEx.DoesNotThrow(() => attribute.Validate("someName@someDomain\uFFEF.com", s_testValidationContext)); // With valid \u character
        }
Exemplo n.º 7
0
        public static void Validate_throws_InvalidOperationException_if_ErrorMessage_is_null()
        {
            var attribute = new EmailAddressAttribute();

            attribute.ErrorMessage = null; // note: this overrides the default value
            Assert.Throws <InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
        }
Exemplo n.º 8
0
 public static void Validate_throws_InvalidOperationException_if_ErrorMessage_and_ErrorMessageResourceName_are_set()
 {
     var attribute = new EmailAddressAttribute();
     attribute.ErrorMessage = "SomeErrorMessage";
     attribute.ErrorMessageResourceName = "SomeErrorMessageResourceName";
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
 }
Exemplo n.º 9
0
        public static void Validate_throws_InvalidOperationException_if_ErrorMessageResourceType_set_but_ErrorMessageResourceName_not_set()
        {
            var attribute = new EmailAddressAttribute();

            attribute.ErrorMessageResourceName = null;
            attribute.ErrorMessageResourceType = typeof(ErrorMessageResources);
            Assert.Throws <InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
        }
Exemplo n.º 10
0
        public static void Validate_throws_InvalidOperationException_if_ErrorMessage_and_ErrorMessageResourceName_are_set()
        {
            var attribute = new EmailAddressAttribute();

            attribute.ErrorMessage             = "SomeErrorMessage";
            attribute.ErrorMessageResourceName = "SomeErrorMessageResourceName";
            Assert.Throws <InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
        }
Exemplo n.º 11
0
        public static void Validate_ErrorMessageResourceNameNotSet_ErrorMessageResourceTypeSet_ThrowsInvalidOperationException()
        {
            var attribute = new EmailAddressAttribute()
            {
                ErrorMessageResourceName = null, ErrorMessageResourceType = typeof(ErrorMessageResources)
            };

            Assert.Throws <InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
        }
Exemplo n.º 12
0
        public static void Validate_ErrorMessageNotSet_ThrowsInvalidOperationException()
        {
            var attribute = new EmailAddressAttribute()
            {
                ErrorMessage = null
            };

            Assert.Throws <InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
        }
Exemplo n.º 13
0
        public static void Validate_throws_for_invalid_local_part()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate("@someDomain.com", s_testValidationContext));                                // no local part
            Assert.Throws <ValidationException>(() => attribute.Validate("\[email protected]", s_testValidationContext));                              // illegal character
            Assert.Throws <ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext));                       // initial dot not allowed
            Assert.Throws <ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext));                       // final dot not allowed
            Assert.Throws <ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext));             // two adjacent dots not allowed
            Assert.Throws <ValidationException>(() => attribute.Validate("firstName(comment)[email protected]", s_testValidationContext));      // parens not allowed
            Assert.Throws <ValidationException>(() => attribute.Validate("firstName\"middleName\"*****@*****.**", s_testValidationContext)); // quotes in middle not allowed
        }
Exemplo n.º 14
0
        public static void Validate_throws_for_invalid_local_part()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws<ValidationException>(() => attribute.Validate("@someDomain.com", s_testValidationContext)); // no local part
            Assert.Throws<ValidationException>(() => attribute.Validate("\[email protected]", s_testValidationContext)); // illegal character
            Assert.Throws<ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // initial dot not allowed
            Assert.Throws<ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // final dot not allowed
            Assert.Throws<ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // two adjacent dots not allowed
            Assert.Throws<ValidationException>(() => attribute.Validate("firstName(comment)[email protected]", s_testValidationContext)); // parens not allowed
            Assert.Throws<ValidationException>(() => attribute.Validate("firstName\"middleName\"*****@*****.**", s_testValidationContext)); // quotes in middle not allowed
        }
Exemplo n.º 15
0
        public static void Validate_successful_for_valid_local_part()
        {
            var attribute = new EmailAddressAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // Simple valid value
            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // numbers are valid
            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // With dot in name
            AssertEx.DoesNotThrow(() => attribute.Validate("\[email protected]", s_testValidationContext)); // With valid \u character
            AssertEx.DoesNotThrow(() => attribute.Validate("!#$%&'*+-/=?^_`|[email protected]", s_testValidationContext)); // With valid (but unusual) characters
            AssertEx.DoesNotThrow(() => attribute.Validate("\"firstName.lastName\"@someDomain.com", s_testValidationContext)); // quotes around whole local part
        }
Exemplo n.º 16
0
        public static void Validate_successful_for_valid_local_part()
        {
            var attribute = new EmailAddressAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext));               // Simple valid value
            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext));                   // numbers are valid
            AssertEx.DoesNotThrow(() => attribute.Validate("*****@*****.**", s_testValidationContext));     // With dot in name
            AssertEx.DoesNotThrow(() => attribute.Validate("\[email protected]", s_testValidationContext));                 // With valid \u character
            AssertEx.DoesNotThrow(() => attribute.Validate("!#$%&'*+-/=?^_`|[email protected]", s_testValidationContext));      // With valid (but unusual) characters
            AssertEx.DoesNotThrow(() => attribute.Validate("\"firstName.lastName\"@someDomain.com", s_testValidationContext)); // quotes around whole local part
        }
Exemplo n.º 17
0
        public static void Validate_throws_for_invalid_domain_name()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate("someName", s_testValidationContext));                 // no domain
            Assert.Throws <ValidationException>(() => attribute.Validate("someName@", s_testValidationContext));                // no domain
            Assert.Throws <ValidationException>(() => attribute.Validate("someName@someDomain", s_testValidationContext));      // Domain must have at least 1 dot
            Assert.Throws <ValidationException>(() => attribute.Validate("someName@[email protected]", s_testValidationContext));         // multiple @'s
            Assert.Throws <ValidationException>(() => attribute.Validate("someName@\0.com", s_testValidationContext));          // illegal character
            Assert.Throws <ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // two adjacent dots not allowed
        }
Exemplo n.º 18
0
        public static void Validate_throws_for_invalid_domain_name()
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws<ValidationException>(() => attribute.Validate("someName", s_testValidationContext)); // no domain
            Assert.Throws<ValidationException>(() => attribute.Validate("someName@", s_testValidationContext)); // no domain
            Assert.Throws<ValidationException>(() => attribute.Validate("someName@someDomain", s_testValidationContext)); // Domain must have at least 1 dot
            Assert.Throws<ValidationException>(() => attribute.Validate("someName@[email protected]", s_testValidationContext)); // multiple @'s
            Assert.Throws<ValidationException>(() => attribute.Validate("someName@\0.com", s_testValidationContext)); // illegal character
            Assert.Throws<ValidationException>(() => attribute.Validate("*****@*****.**", s_testValidationContext)); // two adjacent dots not allowed
        }
Exemplo n.º 19
0
        public static void Validate_InvalidValue_ThrowsValidationException(object value)
        {
            var attribute = new EmailAddressAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate(value, s_testValidationContext));
        }
Exemplo n.º 20
0
        public static void Validate_successful_for_null_address()
        {
            var attribute = new EmailAddressAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate(null, s_testValidationContext)); // Null is valid
        }
Exemplo n.º 21
0
        public static void Validate_successful_for_null_address()
        {
            var attribute = new EmailAddressAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate(null, s_testValidationContext)); // Null is valid
        }
Exemplo n.º 22
0
 public static void Validate_throws_InvalidOperationException_if_ErrorMessageResourceType_set_but_ErrorMessageResourceName_not_set()
 {
     var attribute = new EmailAddressAttribute();
     attribute.ErrorMessageResourceName = null;
     attribute.ErrorMessageResourceType = typeof(ErrorMessageResources);
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
 }
 public static void Validate_ErrorMessageResourceNameNotSet_ErrorMessageResourceTypeSet_ThrowsInvalidOperationException()
 {
     var attribute = new EmailAddressAttribute() { ErrorMessageResourceName = null, ErrorMessageResourceType = typeof(ErrorMessageResources) };
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
 }
 public static void Validate_ErrorMessageNotSet_ThrowsInvalidOperationException()
 {
     var attribute = new EmailAddressAttribute() { ErrorMessage = null };
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
 }
 public static void Validate_InvalidValue_ThrowsValidationException(object value)
 {
     var attribute = new EmailAddressAttribute();
     Assert.Throws<ValidationException>(() => attribute.Validate(value, s_testValidationContext));
 }
 public static void Validate_ValidValue_DoesNotThrow(string value)
 {
     var attribute = new EmailAddressAttribute();
     attribute.Validate(value, s_testValidationContext);
 }
Exemplo n.º 27
0
 public static void Validate_throws_InvalidOperationException_if_ErrorMessage_is_null()
 {
     var attribute = new EmailAddressAttribute();
     attribute.ErrorMessage = null; // note: this overrides the default value
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("InvalidEmailAddress", s_testValidationContext));
 }
Exemplo n.º 28
0
        public static void Validate_ValidValue_DoesNotThrow(string value)
        {
            var attribute = new EmailAddressAttribute();

            attribute.Validate(value, s_testValidationContext);
        }