Exemple #1
0
 internal bool IsValid()
 {
     return(PassportValidator.SimpleValidate(this) &&
            PassportValidator.ValidateBYR(Extract("byr")) &&
            PassportValidator.ValidateIYR(Extract("iyr")) &&
            PassportValidator.ValidateEYR(Extract("eyr")) &&
            PassportValidator.ValidateHeight(Extract("hgt")) &&
            PassportValidator.ValidateHairColor(Extract("hcl")) &&
            PassportValidator.ValidatePattern(Extract("ecl"), "^(amb|blu|brn|gry|grn|hzl|oth)$") &&
            PassportValidator.ValidatePattern(Extract("pid"), @"\d{9}"));
 }
Exemple #2
0
        public override string Level1(string[] input)
        {
            int ctr = 0;

            foreach (var entry in input)
            {
                var passport = ParsePassport(entry);

                if (PassportValidator.SimpleValidate(passport))
                {
                    ctr++;
                }
            }
            return(ctr.ToString());;
        }
Exemple #3
0
        public void CompletePropertiesExcludingCID()
        {
            var passport = new Passport
            {
                Properties = new KeyValuePair <string, string>[]
                {
                    new KeyValuePair <string, string>("byr", "2002"),
                    new KeyValuePair <string, string>("iyr", "2002"),
                    new KeyValuePair <string, string>("eyr", "2002"),
                    new KeyValuePair <string, string>("hgt", "2002"),
                    new KeyValuePair <string, string>("hcl", "2002"),
                    new KeyValuePair <string, string>("ecl", "2002"),
                    new KeyValuePair <string, string>("pid", "2002"),
                }
            };

            bool result = PassportValidator.SimpleValidate(passport);

            result.Should().Be(true);
        }