public void NursesFileReader_ReadCsv_WhenHeaderRowIsMissing_ThrowsHeaderValidationException() { var csvLines = new List <string> { $"{_nurse1Name},{_nurse1Uid}", $"{_nurse2Name},{_nurse2Uid}" }; var mockNursesFile = _createMockNursesFile(csvLines); Assert.Throws <HeaderValidationException>(() => NursesFileReader.readCSV(mockNursesFile)); }
public void NursesFileReader_ReadCsv_WhenHeaderRowIncorrect_CreatesNursesFromCSVRows() { var csvLines = new List <string> { "name,id", $"{_nurse1Name},{_nurse1Uid}", $"{_nurse2Name},{_nurse2Uid}" }; var mockNursesFile = _createMockNursesFile(csvLines); Assert.Throws <HeaderValidationException>(() => NursesFileReader.readCSV(mockNursesFile)); }
/// <param name="start">The start date of the schedule</param> /// <param name="end">The end date of the schedule</param> /// <param name="inputFile">The input file to use for schedule generation</param> public static int Main(DateTime start, DateTime end, NursesFile inputFile) { try { _validateInputs(start, end); var nurses = NursesFileReader.readCSV(inputFile); Console.WriteLine($"\nfound data for {nurses.Count} nurses in {inputFile.FullName}"); Console.WriteLine($"\ncalculating roster for {start.ToString("d")} until {end.ToString("d")}"); var roster = new RosterBuilder().Build(start, end, nurses); roster.Write(); } catch (Exception ex) { Console.WriteLine("\nError: {0}", ex.Message); return((int)ExitCode.Failure); } return((int)ExitCode.Success); }
public void NursesFileReader_ReadCsv_WhenRowsContainValidData_CreatesNursesFromCSVRows() { var csvLines = new List <string> { _headerRow, $"{_nurse1Name},{_nurse1Uid}", $"{_nurse2Name},{_nurse2Uid}" }; var mockNursesFile = _createMockNursesFile(csvLines); var nurses = NursesFileReader.readCSV(mockNursesFile); Assert.Equal(nurses, new List <Nurse> { new Nurse { uid = _nurse1Name, name = _nurse1Uid }, new Nurse { uid = _nurse2Name, name = _nurse2Uid } }); }
public void NursesFileReader_ReadCsv_WhenDuplicateRowsArePresent_SkipsOverThem() { var csvLines = new List <string> { _headerRow, $"{_nurse1Name},{_nurse1Uid}", $"{_nurse2Name},{_nurse2Uid}", $"{_nurse1Name},{_nurse1Uid}" }; var mockNursesFile = _createMockNursesFile(csvLines); var nurses = NursesFileReader.readCSV(mockNursesFile); Assert.Equal(nurses, new List <Nurse> { new Nurse { uid = _nurse1Name, name = _nurse1Uid }, new Nurse { uid = _nurse2Name, name = _nurse2Uid } }); }