Example #1
0
        public void GetSortedNameFreqTest()
        {
            CSVFileContext       ctx     = new CSVFileContext(DataFileName);
            PersonSortRepository sortRep = new PersonSortRepository(ctx);

            string[] sortedFreq = sortRep.GetSortedNameFreq();

            //The expected output
            string[] testOutput = new string[]
            {
                "Johnson, 2",
                "Brown, 1",
                "Heinrich, 1",
                "Jones, 1",
                "Matt, 1",
                "Smith, 1",
                "Tim, 1"
            };

            //Assert if the output is equel to the expected output.
            CollectionAssert.AreEqual(sortedFreq, testOutput);

            //Assert if the sequence of the output is the same as that of the expected output.
            Assert.IsTrue(sortedFreq.ToList().SequenceEqual(testOutput));
        }
Example #2
0
        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));
        }
Example #3
0
        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();
            }
        }