public void AttributeLengthForAddressOverridesAttribute()
        {
            Person person = new Person();
            person.Name = "MyName";
            person.IsMale = true;
            person.Address = "aaa";
            person.friends = 2;

            IClassValidator validator = GetClassValidator(typeof(Person));
            validator.GetInvalidValues(person).Should("Address has not minimum").Be.Empty();
        }
        public void GetAttributeOnlyDefinition()
        {
            Person person = new Person();
            person.Name = string.Empty;
            person.IsMale = true;
            person.Address = "Address";
            person.friends = 2;

            IClassValidator validator = GetClassValidator(typeof(Person));
            validator.GetInvalidValues(person).Should("Name cannot be empty by attribute").Have.Count.EqualTo(1);
        }
        public void AttributeLengthForAddressOverridesXml()
        {
            Person person = new Person();
            person.Name = "MyName";
            person.IsMale = true;
            person.Address = "aaa";
            person.friends = 2;

            IClassValidator validator = GetClassValidator(typeof(Person));

            validator.GetInvalidValues(person).Should(" Address length was short than 5 as set in the attribute").Not.Be.Empty();
        }
        public void GetAttributeOnlyDefinition()
        {
            Person person = new Person();
            person.Name = string.Empty;
            person.IsMale = true;
            person.Address = "Address";
            person.friends = 2;

            IClassValidator validator = GetClassValidator(typeof(Person));
            InvalidValue[] invalids = validator.GetInvalidValues(person);
            Assert.AreEqual(1, invalids.Length, "Name cannot be empty by attribute");
        }
        public void AttributeLengthForAddressOverridesAttribute()
        {
            Person person = new Person();
            person.Name = "MyName";
            person.IsMale = true;
            person.Address = "aaa";
            person.friends = 2;

            IClassValidator validator = GetClassValidator(typeof(Person));
            InvalidValue[] invalids = validator.GetInvalidValues(person);
            Assert.AreEqual(0, invalids.Length, "Address has not minimum");
        }
        public void GetCombinedDefinition()
        {
            Person person = new Person();
            person.Name = "MyName";
            person.IsMale = true;
            person.Address = "Address";
            person.friends = 21;

            IClassValidator validator = GetClassValidator(typeof(Person));
            validator.GetInvalidValues(person).Should("Person cannot have more than 20 friends by Xml").Have.Count.EqualTo(1);

            person.friends = 1;
            validator.GetInvalidValues(person).Should("Person cannot have less than 2 friends by Attribute").Have.Count.EqualTo(1);
        }
        public void AttributeLengthForAddressOverridesXml()
        {
            Person person = new Person();
            person.Name = "MyName";
            person.IsMale = true;
            person.Address = "aaa";
            person.friends = 2;

            IClassValidator validator = GetClassValidator(typeof(Person));

            InvalidValue[] invalids = validator.GetInvalidValues(person);

            Assert.AreEqual(1, invalids.Length, " Address length was short than 5 as set in the attribute");
        }
        public void GetCombinedDefinition()
        {
            Person person = new Person();
            person.Name = "MyName";
            person.IsMale = true;
            person.Address = "Address";
            person.friends = 21;

            IClassValidator validator = GetClassValidator(typeof(Person));
            InvalidValue[] invalids = validator.GetInvalidValues(person);
            Assert.AreEqual(1, invalids.Length, "Person cannot have more than 20 friends by Xml");

            person.friends = 1;
            invalids = validator.GetInvalidValues(person);
            Assert.AreEqual(1, invalids.Length, "Person cannot have less than 2 friends by Attribute");
        }