public void Register_ForAlreadyRegisteredVatId_ThrowsInvalidOperationException() { string vatId = TestVatIdForMan; var citizen1 = CitizenBuilder.NewMan().WithVatId(vatId).Build(); var citizen2 = CitizenBuilder.NewMan().WithVatId(vatId).Build(); registry.Register(citizen1); registry.Register(citizen2); }
public void Register_ForManWithEmptyVatId_AssignsVatIdWithOddCounter() { var citizen = CitizenBuilder.NewMan().WithDate(TestBirthDate).Build(); registry.Register(citizen); int counter = Int32.Parse(citizen.VatId.Substring(5, 4)); Assert.AreEqual(1, counter & 1); }
public void Register_MoreThan5kMenWithSameBirthDate_ExpectedInvalidOperationException() { for (int i = 0; i < 5001; i++) { var m = CitizenBuilder.NewMan().WithDate(TestBirthDate).Build(); registry.Register(m); } }
public void Indexer_WhenCitizenChanges_RegistryHasNoChanges() { var citizen = CitizenBuilder.NewMan().WithDate(SystemDateTime.Now()).Build(); registry.Register(citizen); string id = citizen.VatId; citizen.VatId = "0123456789"; ICitizen foundCitizen = registry[id]; Assert.AreNotEqual(citizen.VatId, foundCitizen.VatId); }
public void Indexer_WithRegisteredVatId_ReturnsCitizenFoundByVatId() { var citizen = CitizenBuilder.NewMan().WithDate(SystemDateTime.Now()).Build(); registry.Register(citizen); ICitizen foundCitizen = registry[citizen.VatId]; Assert.AreEqual(citizen.VatId, foundCitizen.VatId); Assert.AreEqual(citizen.FirstName, foundCitizen.FirstName); Assert.AreEqual(citizen.LastName, foundCitizen.LastName); Assert.AreEqual(citizen.BirthDate, foundCitizen.BirthDate); }
public void Stats_WithOneManInRegistry_ReturnsMessageOneManAndZeroWomenWithLastRegistrationTimeInfo() { var bd = TestTodayDate.AddYears(-1); var citizen = CitizenBuilder.NewMan().WithDate(bd).Build(); var yesterday = TestTodayDate.AddDays(-1); SystemDateTime.Now = () => yesterday; registry.Register(citizen); SystemDateTime.Now = () => TestTodayDate; var msg = registry.Stats(); Assert.AreEqual("1 man and 0 women. Last registration was yesterday", msg); }
public void Stats_WithOneManAndOneWomanInRegistry_ReturnsMessageOneManAndOneWomenWithLastRegistrationTimeInfo() { var bd = TestTodayDate.AddYears(-1); var citizen = CitizenBuilder.NewMan().WithDate(bd).Build(); var twoDaysAgo = TestTodayDate.AddDays(-2); SystemDateTime.Now = () => twoDaysAgo; registry.Register(citizen); citizen = CitizenBuilder.NewWoman().WithDate(bd).Build(); SystemDateTime.Now = () => twoDaysAgo; registry.Register(citizen); SystemDateTime.Now = () => TestTodayDate; var msg = registry.Stats(); Assert.AreEqual("1 man and 1 woman. Last registration was 2 days ago", msg); }