public void TestNoFiles() { MedianProcessor fp = new MedianProcessor(); var result = fp.LoadFileData(@"C:\"); Assert.AreEqual(result, FileLoadResult.NoFilesFound); }
public void TestInvalidPath() { MedianProcessor fp = new MedianProcessor(); var result = fp.LoadFileData(@"x\y\z"); Assert.AreEqual(result, FileLoadResult.InvalidPath); }
static void Main(string[] args) { // Required report writer is intialized to be dependency injected IReportWriter reportWriter = new ConsoleReportWriter(); // CSV file path is retrieved through configuration string csvPath = ConfigurationManager.AppSettings["CSVLocation"]; // Required file processor is initialized IFileProcessor fileProcessor = new MedianProcessor(); // load data in to class objects FileLoadResult fileLoadResult = fileProcessor.LoadFileData(csvPath); if (fileLoadResult == FileLoadResult.Success) { // process data in the class objects fileProcessor.ProcessData(); // print reports fileProcessor.PrintReports(reportWriter); } else { Console.WriteLine("Error: " + fileLoadResult.ToString()); } Console.ReadLine(); }
public void When_data_count_zero_return_false() { var medianProcessor = new MedianProcessor(); var result = medianProcessor.GetMedianResult(new List <EnergyRecord>()); Assert.IsFalse(result.Success); Assert.AreEqual("No records to process median", result.ErrorMessage); }
public void When_data_null_return_false() { var medianProcessor = new MedianProcessor(); var result = medianProcessor.GetMedianResult(null); Assert.IsFalse(result.Success); Assert.AreEqual("No records to process median", result.ErrorMessage); }
public void TestSuccessfulLoad() { var rootPath = AppDomain.CurrentDomain.BaseDirectory; MedianProcessor fp = new MedianProcessor(); var result = fp.LoadFileData(rootPath); Assert.AreEqual(result, FileLoadResult.Success); }
public void TestRequiredDataIsLoadedFromSampleFile() { var rootPath = AppDomain.CurrentDomain.BaseDirectory; MedianProcessor fp = new MedianProcessor(); var result = fp.LoadFileData(rootPath); Assert.AreEqual(result, FileLoadResult.Success); Assert.AreEqual(fp.lpFiles[0].LPDataList.Count, 384); }
public void When_data_available_return_median_data() { var medianProcessor = new MedianProcessor(); var result = medianProcessor.GetMedianResult(records); var energyRecords = result.Value.EnergyRecords; Assert.AreEqual(45.0m, result.Value.Median); Assert.AreEqual(6, energyRecords.Count); Assert.AreEqual(25.0m, energyRecords[0].DataValue); Assert.AreEqual(35.0m, energyRecords[1].DataValue); Assert.AreEqual(40.0m, energyRecords[2].DataValue); Assert.AreEqual(45.0m, energyRecords[3].DataValue); Assert.AreEqual(75.0m, energyRecords[4].DataValue); Assert.AreEqual(75.0m, energyRecords[5].DataValue); }