Пример #1
0
        public void ValidatePassport_ShouldReturnFalse_WhenGivenPassportWithMissingRequiredData()
        {
            var sut = new PassportProcessing();

            var actual = sut.ValidatePassport(sut.ParseInputData("pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980")[0]);

            actual.Should().BeFalse();
        }
Пример #2
0
        public void ValidatePassport_ShouldReturnTrue_WhenGivenValidPassport()
        {
            var sut = new PassportProcessing();

            var actual = sut.ValidatePassport(sut.ParseInputData("pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980 hcl:#623a2f")[0]);

            actual.Should().BeTrue();
        }
Пример #3
0
        public void ValidatePassport_ShouldReturnFalse_WhenGivenDataValuesOutOfRange(string input)
        {
            var sut          = new PassportProcessing();
            var passportData = sut.ParseInputData(input)[0];

            var actual = sut.ValidatePassport(passportData);

            actual.Should().BeFalse();
        }
Пример #4
0
        public void ParseInputData_ShouldReturnCorrectData_WhenGivenOnePassport()
        {
            var sut = new PassportProcessing();

            var actual = sut.ParseInputData("ecl:gry pid:860033327 eyr:2020 hcl:#fffffd\nbyr:1937 iyr:2017 cid:147 hgt:183cm");

            actual.Length.Should().Be(1);
            actual.First().Length.Should().Be(8);
        }
Пример #5
0
        public void ValidatePassport_ShouldReturnNumberOfValidPassports_WhenIteratedOverInputData()
        {
            var input         = File.ReadAllText("Inputs\\day04.txt");
            var sut           = new PassportProcessing();
            var passportsData = sut.ParseInputData(input);

            var count = passportsData.Count(pd => sut.ValidatePassport(pd));

            count.Should().Be(101);
        }