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)); } }
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(); }
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(); }
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(); }