Ejemplo n.º 1
0
        public void PasportHandler_ShouldHave_ValidPassportCountZero()
        {
            int expected = 0;

            List <Passport> passports = serializer.Deserialize <Passport>(invalidPassports).ToList();
            var             handler   = new PassportHandler(passports, new NorthPoleValidator(fieldValidators));
            int             actual    = handler.ValidPassportsCount();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void PassportHandler_ShouldHave_ValidPassportCountTwo()
        {
            int expected = 2;

            List <Passport> passports = serializer.Deserialize <Passport>(passportsInputPart1).ToList();
            var             handler   = new PassportHandler(passports, new NorthPoleValidator(new Dictionary <string, IFieldValidator <string> >()));
            int             actual    = handler.ValidPassportsCount();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        public void PassportHandlerWithMoqValidator_ShouldHave_ValidPassportCountFour()
        {
            int expected = 4;

            Mock <IValidator <Passport> > validator = new Mock <IValidator <Passport> >();

            validator.Setup(v => v.IsValid(It.IsAny <Passport>())).Returns(() => true);

            List <Passport> passports = serializer.Deserialize <Passport>(passportsInputPart1).ToList();
            var             handler   = new PassportHandler(passports, validator.Object);
            int             actual    = handler.ValidPassportsCount();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 4
0
        static void Day4(string passportsInput)
        {
            PassportSerializer serializer = new PassportSerializer();
            List <Passport>    passports  = serializer.Deserialize <Passport>(passportsInput).ToList();

            ConsoleHelper.PrintHeader("DAY 04 - part 01");
            var handler = new PassportHandler(passports, new NorthPoleValidator(new Dictionary <string, IFieldValidator <string> >()));
            int answer  = handler.ValidPassportsCount();

            Console.WriteLine($"Answer: {answer}");

            ConsoleHelper.PrintHeader("DAY 04 - part 02");
            handler = new PassportHandler(passports, new NorthPoleValidator(fieldValidators));
            answer  = handler.ValidPassportsCount();
            Console.WriteLine($"Answer: {answer}");
        }