示例#1
0
        public void SortTest()
        {
            _sorter.parseFile(testPath);
            _sorter.sort();

            List <String[]> testList = new List <string[]>();

            using (StreamReader reader = new StreamReader(@"..\..\sorted-names-test.txt"))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    testList.Add(line.Split());
                }
            }

            Assert.True(_sorter.namesList_sorted.Count == names_Expected);
            Assert.Equal(testList, _sorter.namesList_sorted);
        }
示例#2
0
        static void Main(string[] args)
        {
            var app = new NameSorter();

            Console.WriteLine("nameSorter initialised.\n\n");

            string input = null;

            if (args.Length == 0 || !File.Exists(args[0]))
            {
                while (input == null)
                {
                    Console.WriteLine("Please enter correct file path:\n");
                    input = Console.ReadLine();

                    if (input != null && (File.Exists(Path.GetFullPath(input))))
                    {
                        break;
                    }
                    input = null;
                }
            }
            else
            {
                input = args[0];
            }

            app.parseFile(input);
            Console.Write("Reading file...\n");

            app.sort();
            Console.Write("Sorting...\n");

            app.writeToFile();
            Console.Write("Writing to file...\n\n");

            app.displaySorted();
            Console.Write("\n\nSort Complete. Press Any Key to exit...");
            Console.ReadKey(true);
        }