Exemplo n.º 1
0
        public static void Program_Main_WhenGivenADirectory_ReturnsFailure()
        {
            var inputFile  = new NursesFile("../../../SampleData");
            var returnCode = Program.Main(_start, _end, inputFile);

            Assert.Equal((int)Program.ExitCode.Failure, returnCode);
        }
Exemplo n.º 2
0
        public static void Program_Main_WhenTheInputFileDoesNotExist_ReturnsFailure()
        {
            var inputFile  = new NursesFile("not/found.csv");
            var returnCode = Program.Main(_start, _end, inputFile);

            Assert.Equal((int)Program.ExitCode.Failure, returnCode);
        }
        public void NursesFile_OpenText_WithFileThatDoesNotExist_ThrowsError()
        {
            var fileName   = "does.not.exist";
            var nursesFile = new NursesFile(fileName);

            Assert.Throws <FileNotFoundException>(() =>
                                                  nursesFile.OpenText());
        }
        public void NursesFile_OpenText_WithDirectoryThatDoesNotExist_ThrowsError()
        {
            var fileName   = "does/not/exist.csv";
            var nursesFile = new NursesFile(fileName);

            Assert.Throws <DirectoryNotFoundException>(() =>
                                                       nursesFile.OpenText());
        }
        public void NursesFile_FullName_Get_ReturnsFileFullName()
        {
            var fileName   = "some/file.txt";
            var nursesFile = new NursesFile(fileName);

            Assert.Equal(
                Path.Join(Directory.GetCurrentDirectory(), fileName),
                nursesFile.FullName
                );
        }
Exemplo n.º 6
0
        /// <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);
        }