public static void Validate_throws_for_invalid_values()
        {
            var attribute = new UrlAttribute();

            Assert.Throws<ValidationException>(() => attribute.Validate("file:///foo.bar", s_testValidationContext)); // file scheme
            Assert.Throws<ValidationException>(() => attribute.Validate("foo.png", s_testValidationContext)); // no scheme
        }
        public static void Validate_throws_for_invalid_values()
        {
            var attribute = new UrlAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate("file:///foo.bar", s_testValidationContext)); // file scheme
            Assert.Throws <ValidationException>(() => attribute.Validate("foo.png", s_testValidationContext));         // no scheme
        }
        public static void Validate_successful_for_valid_values()
        {
            var attribute = new UrlAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate(null, s_testValidationContext)); // Null is valid
            AssertEx.DoesNotThrow(() => attribute.Validate("http://foo.bar", s_testValidationContext));
            AssertEx.DoesNotThrow(() => attribute.Validate("https://foo.bar", s_testValidationContext));
            AssertEx.DoesNotThrow(() => attribute.Validate("ftp://foo.bar", s_testValidationContext));
        }
        public static void Validate_successful_for_valid_values()
        {
            var attribute = new UrlAttribute();

            AssertEx.DoesNotThrow(() => attribute.Validate(null, s_testValidationContext)); // Null is valid
            AssertEx.DoesNotThrow(() => attribute.Validate("http://foo.bar", s_testValidationContext));
            AssertEx.DoesNotThrow(() => attribute.Validate("https://foo.bar", s_testValidationContext));
            AssertEx.DoesNotThrow(() => attribute.Validate("ftp://foo.bar", s_testValidationContext));
        }
示例#5
0
        public static void Validate_throws_for_invalid_values()
        {
            var attribute = new UrlAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate("file:///foo.bar", s_testValidationContext));
            Assert.Throws <ValidationException>(() => attribute.Validate("http://user%[email protected]/", s_testValidationContext));
            Assert.Throws <ValidationException>(() => attribute.Validate("foo.png", s_testValidationContext));
            Assert.Throws <ValidationException>(() => attribute.Validate("http://foo\0.bar", s_testValidationContext)); // Illegal character
        }
示例#6
0
        public static void Validate_throws_for_invalid_values()
        {
            var attribute = new UrlAttribute();

            Assert.Throws<ValidationException>(() => attribute.Validate("file:///foo.bar", s_testValidationContext));
            Assert.Throws<ValidationException>(() => attribute.Validate("http://user%[email protected]/", s_testValidationContext));
            Assert.Throws<ValidationException>(() => attribute.Validate("foo.png", s_testValidationContext));
            Assert.Throws<ValidationException>(() => attribute.Validate("http://foo\0.bar", s_testValidationContext)); // Illegal character
        }
        public static void Validate_throws_InvalidOperationException_if_ErrorMessage_is_null()
        {
            var attribute = new UrlAttribute();

            attribute.ErrorMessage = null; // note: this overrides the default value
            Assert.Throws <InvalidOperationException>(() => attribute.Validate("foo.png", s_testValidationContext));
        }
 public static void Validate_throws_InvalidOperationException_if_ErrorMessageResourceType_set_but_ErrorMessageResourceName_not_set()
 {
     var attribute = new UrlAttribute();
     attribute.ErrorMessageResourceName = null;
     attribute.ErrorMessageResourceType = typeof(ErrorMessageResources);
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("foo.png", s_testValidationContext));
 }
 public static void Validate_throws_InvalidOperationException_if_ErrorMessage_and_ErrorMessageResourceName_are_set()
 {
     var attribute = new UrlAttribute();
     attribute.ErrorMessage = "SomeErrorMessage";
     attribute.ErrorMessageResourceName = "SomeErrorMessageResourceName";
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("foo.png", s_testValidationContext));
 }
示例#10
0
        public static void Validate_throws_InvalidOperationException_if_ErrorMessageResourceType_set_but_ErrorMessageResourceName_not_set()
        {
            var attribute = new UrlAttribute();

            attribute.ErrorMessageResourceName = null;
            attribute.ErrorMessageResourceType = typeof(ErrorMessageResources);
            Assert.Throws <InvalidOperationException>(() => attribute.Validate("foo.png", s_testValidationContext));
        }
示例#11
0
        public static void Validate_throws_InvalidOperationException_if_ErrorMessage_and_ErrorMessageResourceName_are_set()
        {
            var attribute = new UrlAttribute();

            attribute.ErrorMessage             = "SomeErrorMessage";
            attribute.ErrorMessageResourceName = "SomeErrorMessageResourceName";
            Assert.Throws <InvalidOperationException>(() => attribute.Validate("foo.png", s_testValidationContext));
        }
示例#12
0
 public static void Validate_throws_InvalidOperationException_if_ErrorMessage_is_null()
 {
     var attribute = new UrlAttribute();
     attribute.ErrorMessage = null; // note: this overrides the default value
     Assert.Throws<InvalidOperationException>(() => attribute.Validate("foo.png", s_testValidationContext));
 }