public void PeopleRepositorySortByAddressTest() { CSVFileContext ctx = new CSVFileContext(DataFileName); PersonSortRepository sortRep = new PersonSortRepository(ctx); string[] sortedAddresses = sortRep.SortByAddressAsc(); //The expected output string[] testOutput = new string[] { "12 Acton St", "98 Chauser St", "31 Clifton Rd", "22 Jones Rd" }; //Assert if the output is equel to the expected output. CollectionAssert.AreEqual(sortedAddresses, testOutput); //Assert if the sequence of the output is the same as that of the expected output. Assert.IsTrue(sortedAddresses.ToList().SequenceEqual(testOutput)); }
static void Main(string[] args) { try { string dataFileName = "People.txt"; CSVFileContext ctx = new CSVFileContext(dataFileName); IPersonSortRepository sortRep = new PersonSortRepository(ctx); string[] sortedAddresses = sortRep.SortByAddressAsc(); Utilities.OutputTestFile.WriteData("SortedAddresses.txt", sortedAddresses); string[] sortedFreq = sortRep.GetSortedNameFreq(); Utilities.OutputTestFile.WriteData("SortedFreq.txt", sortedFreq); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("Done"); Console.ReadKey(); } }