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 }
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 }
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 }
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 }
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 }
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)); }
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)); }
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_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)); }
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_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 }
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 }
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 }
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 }
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 }
public static void Validate_InvalidValue_ThrowsValidationException(object value) { var attribute = new EmailAddressAttribute(); Assert.Throws <ValidationException>(() => attribute.Validate(value, s_testValidationContext)); }
public static void Validate_successful_for_null_address() { var attribute = new EmailAddressAttribute(); AssertEx.DoesNotThrow(() => attribute.Validate(null, s_testValidationContext)); // Null is valid }
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); }
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)); }