Exemple #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.Error.WriteLine("Input filename required.");
                return;
            }

            var path = GetPathFromArgs(args);

            var gradeSorter = new GradeSorter();

            if (gradeSorter.LoadData(path))
            {
                gradeSorter.SortData();
                gradeSorter.SaveData(Helper.GenerateOutputPath(path));
            }
        }
Exemple #2
0
        public void TestLoadDataBadData()
        {
            var gradeSorter = new GradeSorter();

            TestUtilities.GenerateInputFile(DataFactory.GetDataSet(10, true));

            Assert.IsFalse(gradeSorter.LoadData(TestUtilities.GetInputFilePath()));
            Assert.AreEqual(gradeSorter.Data, null);

            TestUtilities.DeleteFiles();
        }
Exemple #3
0
        public void TestSaveData()
        {
            var gradeSorter = new GradeSorter();

            TestUtilities.GenerateInputFile(DataFactory.GetDataSet(10, false));

            Assert.IsTrue(gradeSorter.LoadData(TestUtilities.GetInputFilePath()), "LoadData failed.");

            gradeSorter.SaveData(TestUtilities.GetOutputFilePath());

            Assert.IsTrue(System.IO.File.Exists(TestUtilities.GetOutputFilePath()));

            TestUtilities.DeleteFiles();
        }
Exemple #4
0
        public void TestLoadDataValidFile()
        {
            var random = new Random();
            var count = random.Next(10);
            var gradeSorter = new GradeSorter();

            TestUtilities.GenerateInputFile(DataFactory.GetDataSet(count, false));

            Assert.IsTrue(gradeSorter.LoadData(TestUtilities.GetInputFilePath()), "LoadData failed.");
            Assert.AreNotEqual(gradeSorter.Data, null);
            Assert.AreEqual(gradeSorter.Data.Count, count);

            TestUtilities.DeleteFiles();
        }