Example #1
0
        public void Validate_NestedObject_Invalid()
        {
            var obj = new NestedValidationObject();

            obj.NestedObject = new BasicValidationObject();
            //n.NestedObject.SubNest = null;
            var r = ValidationHandler.Validate(obj);

            Assert.IsTrue(r.Count() > 0);
            Assert.AreEqual(4, r.Count());
        }
        public void Validation_Nested_Object_Null()
        {
            var obj = new NestedValidationObject();

            obj.NestedObject = null;
            obj.GuidID       = Guid.NewGuid().ToString();

            var r     = new List <ValidationResult>();
            var valid = _validator(obj, new ValidationContext(obj), r, true);

            Assert.IsFalse(valid);
        }
Example #3
0
        public void Validate_NestedObject_Valid()
        {
            var obj = new NestedValidationObject();

            obj.GuidID       = Guid.NewGuid().ToString();
            obj.NestedObject = new BasicValidationObject()
            {
                StringProperty = "Some String", EmailProperty = "*****@*****.**", IntegerProperty = 3
            };
            var r = ValidationHandler.Validate(obj);

            Assert.IsTrue(r == null);
        }
        public void Validation_Nested_Valid()
        {
            var obj = new NestedValidationObject();

            obj.NestedObject = new BasicValidationObject()
            {
                StringProperty = "Some String", EmailProperty = "*****@*****.**", IntegerProperty = 3
            };
            obj.GuidID = Guid.NewGuid().ToString();

            var r     = new List <ValidationResult>();
            var valid = _validator(obj, new ValidationContext(obj), r, true);

            Assert.IsTrue(valid);
            Assert.AreEqual(0, r.Count);
        }
        public void Validation_Nested_Object_Invalid()
        {
            var input = "This is a long string that should not pass validation so we are going to continue rambling on and on for a while meow";
            var obj   = new NestedValidationObject();

            obj.NestedObject = new BasicValidationObject()
            {
                StringProperty = input, EmailProperty = "invalid email", IntegerProperty = 45
            };
            obj.GuidID = "Not A Guid";

            var r     = new List <ValidationResult>();
            var valid = _validator(obj, new ValidationContext(obj), r, true);

            Assert.IsFalse(valid);
        }