public void XmlFileReader_CanLoadXMLProvided_WrongFileName() { XmlFileReaderService xmlFileReaderService = new XmlFileReaderService(); var stringPath = @"C:\Users\ashaikh\source\repos\GlobalPlanningModel\GlobalPlanningModel\App_Data\Data1.xml"; var result = xmlFileReaderService.ReadAllScenarios(stringPath); Assert.IsNotNull(result); Assert.IsTrue(result.Count > 0); }
static async Task Main(string[] args) { bool endApplication = false; while (!endApplication) { IEncryptService encryptService = new EncryptService(); ITextFileReaderService textFileReader = new TextFileReaderService(encryptService); IXmlFileReaderService xmlFileReaderService = new XmlFileReaderService(encryptService); IJsonFileReaderService jsonFileReaderService = new JsonFileReaderService(encryptService); IRoleService roleService = new RoleService(); Console.Clear(); bool errorToRead = true; while (errorToRead) { UseRole(roleService); FileType fileType = SelectFileType(roleService); try { string[] fileNames; fileNames = FilesToRead(fileType); if ((bool)!fileNames?.Any()) { Console.WriteLine($"No file found for type {fileType}. Make sure you have a file ending with '.fileType' " + "in the Files folder of the 'InterparkingEx3' project. Also check that the file is set to " + "'copy always' otherwise it will not work.", ConsoleColor.Red); } else { switch (fileType) { case FileType.Xml: await ReadXml(fileNames, xmlFileReaderService, roleService); break; case FileType.Txt: await ReadTxtFile(fileNames, roleService, textFileReader, fileType); break; case FileType.Json: await ReadJsonFile(fileNames, jsonFileReaderService, roleService); break; } errorToRead = false; } } catch (Exception e) { WriteException(e); errorToRead = true; } } bool inputIsCorrect = false; while (!inputIsCorrect) { Console.WriteLine("Do you still want to read a file? (y/n)"); switch (Console.ReadLine()) { case "y": inputIsCorrect = true; break; case "n": inputIsCorrect = true; endApplication = true; break; default: Console.WriteLine("The value entered is incorrect"); inputIsCorrect = false; break; } } } }