Beispiel #1
0
        public void ReflectionAttributeTest()
        {
            Type      type         = null;         // TODO: Initialize to an appropriate value
            string    propertyName = string.Empty; // TODO: Initialize to an appropriate value
            Validator expected     = null;         // TODO: Initialize to an appropriate value
            Validator actual;

            actual = ReflcationClassProperty.GetValidator(type, propertyName);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #2
0
        public void GetValidatorTest()
        {
            Type      type         = typeof(Person);
            string    propertyName = "Name";                                            // TODO: Initialize to an appropriate value
            Validator expected     = new AndCompositeValidator(new NotNullValidator()); // TODO: Initialize to an appropriate value
            Validator actual;

            actual = ReflcationClassProperty.GetValidator(type, propertyName);
            Assert.IsTrue(actual is AndCompositeValidator);
            var actualValidator = actual as AndCompositeValidator;
            var children        = new List <Validator>(actualValidator.ListValidator);

            Assert.IsTrue(children.Count == 1);
            Assert.IsTrue(children[0] is NotNullValidator);
        }
Beispiel #3
0
        protected string CheckValidation(string pName)
        {
            var type      = this.GetType();
            var p         = type.GetProperty(pName);
            var value     = p.GetValue(this, null);
            var validator = ReflcationClassProperty.GetValidator(type, pName);
            var result    = validator.isValid(value);

            if (!result.Isvalid)
            {
                return(result.GetValidationResult(0).Message);
            }

            return(null);
        }