IsValid() public method

public IsValid ( object value ) : bool
value object
return bool
コード例 #1
0
        public void IsValid_Object()
        {
            var attr = new ValidateFooAttribute();

            AssertExtensions.Throws <NotImplementedException> (() => {
                // It calls IsValid (object, validationContext) which throws the NIEX, but when that overload is called directly, there's
                // no exception.
                //
                // at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)
                // at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
                // at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 450
                attr.IsValid(null);
            }, "#A1-1");

            AssertExtensions.Throws <NotImplementedException> (() => {
                attr.IsValid("stuff");
            }, "#A1-2");
        }
コード例 #2
0
        public void IsValid_Object()
        {
            var attr = new ValidateFooAttribute();

            try {
                attr.IsValid(null);
                Assert.Fail("#A1-1");
            } catch (NotImplementedException) {
                // success
            }

            try {
                attr.IsValid("stuff");
                Assert.Fail("#A1-2");
            } catch (NotImplementedException) {
                // success
            }
        }
コード例 #3
0
		public void IsValid_Object ()
		{
			var attr = new ValidateFooAttribute ();

			try {
				attr.IsValid (null);
				Assert.Fail ("#A1-1");
			} catch (NotImplementedException) {
				// success
			}

			try {
				attr.IsValid ("stuff");
				Assert.Fail ("#A1-2");
			} catch (NotImplementedException) {
				// success
			}
		}
コード例 #4
0
		public void IsValid_Object ()
		{
			var attr = new ValidateFooAttribute ();

			AssertExtensions.Throws <NotImplementedException> (() => {
				// It calls IsValid (object, validationContext) which throws the NIEX, but when that overload is called directly, there's
				// no exception.
				//
				// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)
				// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
				// at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 450
				attr.IsValid (null);
			}, "#A1-1");
			
			AssertExtensions.Throws <NotImplementedException> (() => {
				attr.IsValid ("stuff");
			}, "#A1-2");
		}