public void Create_ShouldCreateNextNewRegistrationNumber_When_Next_Is_Available_And_Are_Gapps_In_Numbers() { const int nextAvailableNumber = 99999; string expectedRegistrationNumber = $"1-0{nextAvailableNumber}"; var unavailableNumbers = RegistrationNumbersGenerator.Generate(limit: nextAvailableNumber); var sut = RegistrationNumber.Create(unavailableNumbers); Assert.AreEqual(expectedRegistrationNumber, sut.FirstPart + sut.SecondPart); }
public void Create_ShouldCreateFirstMissingAvailableRegistrationNumber_When_Are_Gapps_In_Numbers_And_RegistrationNumbers_Reached_Max() { int firstAvailableNumber = 423; int[] missingRegistrationNumbers = new int[] { firstAvailableNumber, 23441 }; string expectedRegistrationNumber = $"1-000{firstAvailableNumber}"; var unavailableNumbers = RegistrationNumbersGenerator.Generate(numbersToSkip: missingRegistrationNumbers); var sut = RegistrationNumber.Create(unavailableNumbers); Assert.AreEqual(expectedRegistrationNumber, sut.FirstPart + sut.SecondPart); }
public void Create_ShouldCreateEmployee_With_RegistrationNumber_And_Id_Filled() { var dateOfBirth = Today.AddYears(-40); const int firstAvailableNumber = 699; string expectedRegistrationNumber = $"1-000{firstAvailableNumber}"; var unavailableNumbers = RegistrationNumbersGenerator.Generate(firstAvailableNumber); var sut = Employee.Create(CorrectPesel, dateOfBirth, "LastName", "FirstName", null, "Male", Today, unavailableNumbers); Assert.IsTrue(sut.Id != Guid.Empty, "Employee Id should not be empty"); Assert.IsTrue(sut.RegistrationNumber != null, "Employee Registration Number should not be null"); Assert.AreEqual(expectedRegistrationNumber, sut.RegistrationNumber.ToString()); }
public void Create_ShouldThrowRegistrationNumbersReachedMaxException_When_RegistrationNumber_Reached_Max() { var unavailableNumbers = RegistrationNumbersGenerator.Generate(); Assert.Throws <RegistrationNumbersReachedMaxException>(() => RegistrationNumber.Create(unavailableNumbers)); }