public void test_Covariance_returns_correct_result() { /*Covariance for testList and testList2 calculated with R: -9.925833. * For test result is rounded to four decimals.*/ Assert.AreEqual(Math.Round(-9.9258, 4), Math.Round(Variance.Covariance(testList, testList2), 4)); }
public void test_Covariance_null_lists_throws_MathError() { /*If either of Covariance parameter lists are null, MathError should be thrown * with error "Parameter list cannot be a null item"*/ MathError err = Assert.Throws <MathError>(() => Variance.Covariance(testList, null)); Assert.AreEqual("Parameter list cannot be a null item", err.error); }
public void test_Covariance_different_Counts_throw_MathError() { /*MathError with error message "Variable lists not the same length" should be thrown.*/ List <double> list1 = new List <double>(); list1.Add(2.2); MathError err = Assert.Throws <MathError>(() => Variance.Covariance(testList, list1)); Assert.AreEqual("Variable lists not the same length", err.error); }
public void test_Covariance_0_Count_lists_throws_MathError() { /*If both list are of 0 length, MathError should be thrown with error "Parameter lists have 0 items"*/ List <double> list1 = new List <double>(); List <double> list2 = new List <double>(); MathError err = Assert.Throws <MathError>(() => Variance.Covariance(list1, list2)); Assert.AreEqual("Parameter lists have 0 items", err.error); list1 = null; list2 = null; }