public void WritetoFile_PersonAddresses_ShouldSucceed() { var directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent; if (directoryInfo == null) { return; } if (directoryInfo.Parent == null) { return; } // read the csv file string filename = Path.Combine(directoryInfo.Parent.FullName, "Data\\data.csv"); List <Row> rows = FileProcessor.ReadFile(filename); List <Person> person = PersonProcessor.GetPersonList(rows); //Process the data before writing it to a text file List <string> orderDictionary = PersonProcessor.PersonsAddresses(person); List <Row> rowList = orderDictionary.Select(address => new Row() { LineText = address }).ToList(); string writeFileName = Path.Combine(directoryInfo.Parent.FullName, "Data\\Address.txt"); // check and delete file first before creating a new file if (File.Exists(writeFileName)) { File.Delete(writeFileName); } FileProcessor.WriteFile(writeFileName, rowList); bool fileExist = File.Exists(writeFileName); Assert.IsTrue(fileExist); }
public void GetPersonAddresses_ShouldSucceed() { var directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent; if (directoryInfo == null) { return; } if (directoryInfo.Parent == null) { return; } // read the csv data file string filename = Path.Combine(directoryInfo.Parent.FullName, "Data\\data.csv"); List <Row> rows = FileProcessor.ReadFile(filename); //Process the data List <Person> person = PersonProcessor.GetPersonList(rows); List <string> orderDictionary = PersonProcessor.PersonsAddresses(person); Assert.AreEqual(8, orderDictionary.Count); }