public void ParseConfig_ValidConfig_ReturnObject() { //test if at least one row can be matched var strArr = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt ConfigTest2.txt"); var testObj = new CalculateStatistics(strArr); var dict = CalculateStatistics.GetCalculationTypes(); var taskList = testObj.ParseConfig(dict); Assert.AreEqual(testObj.ParseConfig(dict).Count, 3); }
public void ParseConfig_InvalidConfig_ReturnNull() { //test if at least one row can be matched var strArr = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt ConfigTest1.txt"); var testObj = new CalculateStatistics(strArr); Assert.AreEqual(testObj.ParseConfig(CalculateStatistics.GetCalculationTypes()).Count(), 0); }
public void ProcessData_ResvAssumedMaxMax_ReturnCorrectCalculation() { var strArr = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt ResvAssumedMaxMax.txt"); var testObj = new CalculateStatistics(strArr); var dict = CalculateStatistics.GetCalculationTypes(); var taskList = testObj.ParseConfig(dict); testObj.ProcessData(taskList); string actual = taskList[0].ReturnFinal().Split('\t')[2]; double calculated = new[] { -27923645.44, -27923645.44, -27923645.44 }.Max(); Console.WriteLine("acutal is {0}, calculated is {1}", actual, calculated.ToString()); Assert.AreEqual(actual, calculated.ToString()); }
public void ProcessData_CashPremAverageLast_ReturnCorrectCalculation() { var strArr = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt CashPremAverageLast.txt"); var testObj = new CalculateStatistics(strArr); var dict = CalculateStatistics.GetCalculationTypes(); var taskList = testObj.ParseConfig(dict); testObj.ProcessData(taskList); string actual = taskList[0].ReturnFinal().Split('\t')[2]; double calculated = new[] { 84655947.13, 84655914.86, 84655947.13 }.Average(); Console.WriteLine("acutal is {0}, calculated is {1}", actual, calculated.ToString()); Assert.AreEqual(actual, calculated.ToString()); }
public void ProcessData_AvePolLoanYieldAverageFirstCashPremAverageLast_ReturnCorrectCalculation() { var strArr = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt AvePolLoanYieldAverageFirstCashPremAverageLast.txt"); var testObj = new CalculateStatistics(strArr); var dict = CalculateStatistics.GetCalculationTypes(); var taskList = testObj.ParseConfig(dict); testObj.ProcessData(taskList); string actual = taskList[0].ReturnFinal().Split('\t')[2]; double calculated = new[] { 0.00, 0.00, 0.00 }.Average(); string actual2 = taskList[1].ReturnFinal().Split('\t')[2]; double calculated2 = new[] { 84655947.13, 84655914.86, 84655947.13 }.Average(); Assert.AreEqual(actual + actual2, calculated.ToString() + calculated2.ToString()); }