コード例 #1
0
        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
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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
ファイル: UrlAttributeTests.cs プロジェクト: johnhhm/corefx
        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
        }
コード例 #7
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));
        }
コード例 #8
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));
 }
コード例 #9
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));
 }
コード例 #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));
 }