Inheritance: ValidateBarAttribute
        public void Validate_Object_ValidationContext()
        {
            var attr = new ValidateBazAttribute();

            try
            {
                attr.Validate("stuff", (ValidationContext)null);
                Assert.Fail("#A1");
            }
            catch (ArgumentNullException)
            {
                // success
            }

            var vc = new ValidationContext("stuff", null, null);

            try
            {
                attr.Validate(null, vc);
                Assert.Fail("#A2-1");
            }
            catch (ValidationException)
            {
                // success
            }
            Assert.AreEqual(3, attr.Calls.Count, "#A2-1");
            Assert.AreEqual("ValidationResult IsValid (object value, ValidationContext validationContext)", attr.Calls [0], "#A2-2");
            Assert.AreEqual("bool IsValid (object value)", attr.Calls [1], "#A2-3");
            Assert.AreEqual("string FormatErrorMessage (string name)", attr.Calls [2], "#A2-4");
        }
Ejemplo n.º 2
0
        public void Validate_Object_String()
        {
            var attr = new ValidateBazAttribute();

            try {
                attr.Validate(null, (string)null);
                Assert.Fail("#A2");
            } catch (ValidationException) {
                // success
            }

            Assert.AreEqual(2, attr.Calls.Count, "#A2-1");
            Assert.AreEqual("bool IsValid (object value)", attr.Calls [0], "#A2-2");
            Assert.AreEqual("string FormatErrorMessage (string name)", attr.Calls [1], "#A2-3");
        }
Ejemplo n.º 3
0
		public void Validate_Object_String ()
		{
			var attr = new ValidateBazAttribute ();

			try {
				attr.Validate (null, (string) null);
				Assert.Fail ("#A2");
			} catch (ValidationException) {
				// success
			}

			Assert.AreEqual (2, attr.Calls.Count, "#A2-1");
			Assert.AreEqual ("bool IsValid (object value)", attr.Calls [0], "#A2-2");
			Assert.AreEqual ("string FormatErrorMessage (string name)", attr.Calls [1], "#A2-3");
		}
Ejemplo n.º 4
0
		public void Validate_Object_ValidationContext ()
		{
			var attr = new ValidateBazAttribute ();

			try {
				attr.Validate ("stuff", (ValidationContext) null);
				Assert.Fail ("#A1");
			} catch (ArgumentNullException) {
				// success
			}

			var vc = new ValidationContext ("stuff", null, null);
			try {
				attr.Validate (null, vc);
				Assert.Fail ("#A2-1");
			} catch (ValidationException) {
				// success
			}
			Assert.AreEqual (3, attr.Calls.Count, "#A2-1");
			Assert.AreEqual ("ValidationResult IsValid (object value, ValidationContext validationContext)", attr.Calls [0], "#A2-2");
			Assert.AreEqual ("bool IsValid (object value)", attr.Calls [1], "#A2-3");
			Assert.AreEqual ("string FormatErrorMessage (string name)", attr.Calls [2], "#A2-4");
		}