public void GivenTOUFileReaderService_WhenFileNameIsInvalid_ThenItShouldThrowException() { //arrange string fileName = "C:\\Test.Csv"; //act TOUFileReaderService tOUFileReaderService = new TOUFileReaderService(fileName); tOUFileReaderService.ProcessCSVFile(); //assert }
public void GivenTOUFileReaderService_WhenFileNameIsValid_ThenItShouldProcessTheFile() { //arrange string folderPath = "C:\\ERM-Power-code\\Sample files (1) (2) (1) (1)"; var files = Directory.GetFiles(folderPath, "*.csv"); var mockMedianPriceCalculatorService = new Mock <MedianPriceCalculatorService>(); mockMedianPriceCalculatorService.Setup(x => x.CalculateMedianPrice()).Returns(100); var mockGenerateConsoleOutputService = new Mock <GenerateCSVOutputService>(); mockGenerateConsoleOutputService.Setup(x => x.GenerateConsoleOutput()).Returns(new List <ConsoleOutput>()); //act TOUFileReaderService tOUFileReaderService = new TOUFileReaderService(files[1]); var output = tOUFileReaderService.ProcessCSVFile(); //assert Assert.IsNotNull(output); }
static void Main(string[] args) { string folderPath = ConfigurationManager.AppSettings["CSVFileLocation"]; foreach (string file in Directory.EnumerateFiles(folderPath, "*.csv")) { string fileName = Path.GetFileName(file); if (fileName.StartsWith("TOU", true, CultureInfo.CurrentCulture)) { TOUFileReaderService tOUFileReaderService = new TOUFileReaderService(file); PrintCSVOutput printCSVOutput = new PrintCSVOutput(tOUFileReaderService); printCSVOutput.PrintAtConsole(); } else if (fileName.StartsWith("LP", true, CultureInfo.CurrentCulture)) { LPFileReaderService lPFileReaderService = new LPFileReaderService(file); PrintCSVOutput printCSVOutput = new PrintCSVOutput(lPFileReaderService); printCSVOutput.PrintAtConsole(); } } Console.ReadKey(); }