public void NthRoot_TakesArguments_ReturnCalculatedRoots() { //< param name = "result" > It's array wich contains testcases for FindNthRoot.NthRoot method. //</ param > double[,] result = new double[, ] { // Format {numb, exp, accurancy, expected value}. Where "numb" is the base of the arithmetic root, // "exp" is the exponent of arithmetic root, accurancy is the setted accurancy { 1, 5, 0.0001, 1 }, { 8, 3, 0.0001, 2 }, { 0.001, 3, 0.00010, 0.1 }, { 0.04100625, 4, 0.0001, 0.45 }, { 8, 3, 0.0001, 2 }, { 0.0279936, 7, 0.0001, 0.6 }, { 0.0081, 4, 0.1, 0.3 }, { -0.008, 3, 0.1, -0.2 }, { 0.004241979, 9, 0.00000001, 0.545 }, { 9, 2, 0.1, 3 }, { 100, 2, 0.1, 10 }, { -27, 3, 0.1, -3 }, { -14, 5, 0.001, -1.695 }, { 0.51, 4, 0.000001, 0.845 }, { 2.811, 6, 0.0001, 1.188 } }; for (int i = 0; i < result.GetLength(0); i++) { Assert.AreEqual(FindNthRoot.NthRoot(result[i, 0], result[i, 1], result[i, 2]), result[i, 3]); } }
public void NthRootNUnitTests_WithNotValidAccurancy_ThrowsArgumentException() { Assert.That(() => FindNthRoot.NthRoot(9, 2, -1), Throws.ArgumentException.With.Message .EqualTo("The accurancy is not valid")); }
public void NthRootNUnitTests_WithNegativeRootExponent_ThrowsArgumentException() { Assert.That(() => FindNthRoot.NthRoot(9, -2, 0.001), Throws.ArgumentException.With.Message .EqualTo("Exponent should be only positive number")); }
public void NthRootNUnitTests_WithNegativeArguments_ThrowsArgumentException() { Assert.That(() => FindNthRoot.NthRoot(-9, 2, 0.001), Throws.ArgumentException.With.Message .EqualTo("Not execute even-numbered roots from negative number")); }
public double NthRootNUnitTests(double numb, double exp, double accurancy) { return(FindNthRoot.NthRoot(numb, exp, accurancy)); }
public void NthRoot_WithNotValidAccurancy_ThrowsArgumentException() => FindNthRoot.NthRoot(9, 2, -1);
public void NthRoot_WithNegativeRootExponent_ThrowsArgumentExceptio() => FindNthRoot.NthRoot(9, -2, 0.001);