public void RulesProviderReturnsFourValidatedProperties()
        {
            var rulesProvider = new ValidatorRulesProvider();

            var rules = rulesProvider.GetRulesFromType(typeof(ValidatableClass));

            var numRules = rules.Keys.Count();

            Assert.AreEqual(4, numRules);
        }
        public void RulesProviderReturnsOnlyStringLengthRuleForFirstName()
        {
            var rulesProvider = new ValidatorRulesProvider();

            var allRules = rulesProvider.GetRulesFromType(typeof(ValidatableClass));

            var firstNameRules = allRules["FirstName"];

            var firstNameRulesList = firstNameRules.ToList();

            Assert.AreEqual(1, firstNameRulesList.Count);
            Assert.AreEqual("StringLength", firstNameRulesList[0].RuleName);
        }
        public void RulesProviderReturnsCorrectMessageForAge()
        {
            var rulesProvider = new ValidatorRulesProvider();

            var allRules = rulesProvider.GetRulesFromType(typeof(ValidatableClass));

            var ageRules = allRules["Age"];

            var ageRulesList = ageRules.OrderBy(x => x.RuleName).ToList();

            Assert.AreEqual(1, ageRulesList.Count);

            Assert.AreEqual("You can't be that old or young!", ageRulesList[0].ErrorMessage);
        }
        public void RulesProviderReturnsTwoRulesForLastName()
        {
            var rulesProvider = new ValidatorRulesProvider();

            var allRules = rulesProvider.GetRulesFromType(typeof(ValidatableClass));

            var lastNameRules = allRules["LastName"];

            var lastNameRulesList = lastNameRules.OrderBy(x=>x.RuleName).ToList();

            Assert.AreEqual(2, lastNameRulesList.Count);

            Assert.AreEqual("Required", lastNameRulesList[0].RuleName);
            Assert.AreEqual("StringLength", lastNameRulesList[1].RuleName);
        }