public void Derived_ValidationAttribute_Short_Form_Called_With_Error() {
     MyValAttr m = new MyValAttr("error message");
     Assert.IsFalse(m.IsValid("stuff"));
     Assert.IsTrue(m._longIsValidCalled);
     Assert.IsNull(m._validationContext);
     Assert.AreEqual("stuff", m._object);
 }
示例#2
0
        public void Derived_ValidationAttribute_Short_Form_Called_With_Error()
        {
            MyValAttr m = new MyValAttr("error message");

            Assert.IsFalse(m.IsValid("stuff"));
            Assert.IsTrue(m._longIsValidCalled);
            Assert.IsNull(m._validationContext);
            Assert.AreEqual("stuff", m._object);
        }
        public void Derived_ValidationAttribute_Long_Form_Called() {
            MyValAttr m = new MyValAttr();
            ValidationContext context = new ValidationContext(new object(), null, null);
            ValidationResult result = m.GetValidationResult("stuff", context);

            Assert.IsTrue(m._longIsValidCalled);
            Assert.IsNotNull(m._validationContext);
            Assert.IsNull(result);
            Assert.AreEqual("stuff", m._object);
        }
示例#4
0
        public void Derived_ValidationAttribute_Long_Form_Called()
        {
            MyValAttr         m       = new MyValAttr();
            ValidationContext context = new ValidationContext(new object(), null, null);
            ValidationResult  result  = m.GetValidationResult("stuff", context);

            Assert.IsTrue(m._longIsValidCalled);
            Assert.IsNotNull(m._validationContext);
            Assert.IsNull(result);
            Assert.AreEqual("stuff", m._object);
        }
示例#5
0
        public void Derived_ValidationAttribute_Long_Form_Defaults_Error_Message()
        {
            MyValAttr m = new MyValAttr(null);

            m.ErrorMessage = "stock error message for {0}";
            ValidationContext context = new ValidationContext(new MyObject(), null, null);

            context.MemberName = "Member";
            ValidationResult result = m.GetValidationResult("stuff", context);

            Assert.IsNotNull(result);
            Assert.AreEqual("stock error message for Member", result.ErrorMessage);
        }
        public void Derived_ValidationAttribute_Long_Form_Called_With_Error() {
            MyValAttr m = new MyValAttr("error message");
            ValidationContext context = new ValidationContext(new object(), null, null);
            context.MemberName = "member";
            ValidationResult result = m.GetValidationResult("stuff", context);

            Assert.IsTrue(m._longIsValidCalled);
            Assert.IsNotNull(m._validationContext);
            Assert.IsNotNull(result);
            Assert.AreEqual("stuff", m._object);
            Assert.AreEqual("error message", result.ErrorMessage);
            IEnumerable<string> memberNames = result.MemberNames;
            Assert.IsNotNull(memberNames);
            Assert.AreEqual(1, memberNames.Count());
            Assert.AreEqual("member", memberNames.First());
        }
示例#7
0
        public void Derived_ValidationAttribute_Long_Form_Called_With_Error()
        {
            MyValAttr         m       = new MyValAttr("error message");
            ValidationContext context = new ValidationContext(new object(), null, null);

            context.MemberName = "member";
            ValidationResult result = m.GetValidationResult("stuff", context);

            Assert.IsTrue(m._longIsValidCalled);
            Assert.IsNotNull(m._validationContext);
            Assert.IsNotNull(result);
            Assert.AreEqual("stuff", m._object);
            Assert.AreEqual("error message", result.ErrorMessage);
            IEnumerable <string> memberNames = result.MemberNames;

            Assert.IsNotNull(memberNames);
            Assert.AreEqual(1, memberNames.Count());
            Assert.AreEqual("member", memberNames.First());
        }
        public void Derived_ValidationAttribute_Long_Form_Defaults_Error_Message() {
            MyValAttr m = new MyValAttr(null);
            m.ErrorMessage = "stock error message for {0}";
            ValidationContext context = new ValidationContext(new MyObject(), null, null);
            context.MemberName = "Member";
            ValidationResult result = m.GetValidationResult("stuff", context);

            Assert.IsNotNull(result);
            Assert.AreEqual("stock error message for Member", result.ErrorMessage);
        }