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); }
public void CountryIdOfThirdPassport_ShouldBe_Null() { var serializer = new PassportSerializer(); List <Passport> passports = serializer.Deserialize <Passport>(passportsInput).ToList(); Assert.Null(passports[2].cid); }
public void DeserializationOfString_ShouldGiveObjectOfType_ListOfPassport() { var serializer = new PassportSerializer(); var deserializedPassport = serializer.Deserialize <Passport>(passportsInput); Assert.IsType <List <Passport> >(deserializedPassport); }
public void IssueYearOfSecondPassport_ShouldBe_2013() { var expected = "2013"; var serializer = new PassportSerializer(); List <Passport> passports = serializer.Deserialize <Passport>(passportsInput).ToList(); Assert.Equal(expected, actual: passports[1].iyr); }
public void CountOfPassports_ShouldBe_Four() { var expected = 4; var serializer = new PassportSerializer(); List <Passport> passports = serializer.Deserialize <Passport>(passportsInput).ToList(); Assert.Equal(expected, actual: passports.Count); }
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}"); }