コード例 #1
0
        public void Validator_Object_No_Attributes() {
            ValTestNoAttributesClass instance = new ValTestNoAttributesClass();
            ValidationContext context = new ValidationContext(instance, null, null);
            bool isValid = Validator.TryValidateObject(instance, context, null);
            Assert.IsTrue(isValid);

            List<ValidationResult> output = new List<ValidationResult>();
            instance = new ValTestNoAttributesClass();
            context = new ValidationContext(instance, context, context.Items);
            isValid = Validator.TryValidateObject(instance, context, output);
            Assert.IsTrue(isValid);
            Assert.AreEqual(0, output.Count);
        }
コード例 #2
0
        public void Validator_Object_No_Attributes()
        {
            ValTestNoAttributesClass instance = new ValTestNoAttributesClass();
            ValidationContext        context  = new ValidationContext(instance, null, null);
            bool isValid = Validator.TryValidateObject(instance, context, null);

            Assert.IsTrue(isValid);

            List <ValidationResult> output = new List <ValidationResult>();

            instance = new ValTestNoAttributesClass();
            context  = new ValidationContext(instance, context, context.Items);
            isValid  = Validator.TryValidateObject(instance, context, output);
            Assert.IsTrue(isValid);
            Assert.AreEqual(0, output.Count);
        }