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]);
     }
 }
Ejemplo n.º 2
0
        public void NewtonMethod_CorrectInputValues_PositiveTest(double number, double n, double accuracy, double ExpectedResult)
        {
            double actual   = FindNthRoot.NewtonMethod(number, n, accuracy);
            double expected = ExpectedResult;

            NUnit.Framework.Assert.AreEqual(actual, expected, accuracy);
        }
Ejemplo n.º 3
0
        public double DoCalculationTest(double number, int degree, double precision)
        {
            // arrange
            var findNthRootObj = new FindNthRoot();

            // act + assert
            return(findNthRootObj.DoCalculation(number, degree, precision));
        }
Ejemplo n.º 4
0
        public void FindRootTest_00081and4and01_03result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(0.0081, 4, 0.1);

            Assert.AreEqual(0.3, testValue);
        }
Ejemplo n.º 5
0
        public void FindRootTest_00279936and7and0001_06result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(0.0279936, 7, 0.0001);

            Assert.AreEqual(0.6, testValue);
        }
Ejemplo n.º 6
0
        public void FindRootTest_8and3and0001_2result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(8, 3, 0.0001);

            Assert.AreEqual(2, testValue);
        }
Ejemplo n.º 7
0
        public void FindRootTest_004100625and4and0001_045result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(0.04100625, 4, 0.0001);

            Assert.AreEqual(0.45, testValue);
        }
Ejemplo n.º 8
0
        public void FindRootTest_Negative0008and3and01_Negative02result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(-0.008, 3, 0.1);

            Assert.AreEqual(-0.2, testValue);
        }
Ejemplo n.º 9
0
        public void FindRootTest_1and5and0001_1result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(1, 5, 0.0001);

            Assert.AreEqual(1, testValue);
        }
Ejemplo n.º 10
0
        public void doCalculationTest_Number_Degree_Precision_ArgumentOutOfRangeException
            (double number, int degree, double precision)
        {
            // arrange
            var findNthRootObj = new FindNthRoot();

            // act + assert
            Assert.Throws <ArgumentOutOfRangeException>(
                () => findNthRootObj.DoCalculation(number, degree, precision));
        }
Ejemplo n.º 11
0
        public void Test_FindRoot(double number, int powerRoot, double eps, double expected)
        {
            double actual = FindNthRoot.FindRoot(number, powerRoot, eps);

            Assert.AreEqual(expected, actual, eps);
        }
Ejemplo n.º 12
0
 public void Insertion_InputValuesLess0_ThrowsArgumentException(double number, double n, double accuracy)
 {
     NUnit.Framework.Assert.Throws <ArgumentException>(() => FindNthRoot.NewtonMethod(number, n, accuracy));
 }
Ejemplo n.º 13
0
 public void FindRoot_NegativeAccuracy_ArgumentException(double value, double power, double accuracy)
 {
     Assert.Throws <ArgumentException>(() => FindNthRoot.FindRoot(value, power, accuracy));
 }
 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 double NthRootNUnitTests(double numb, double exp, double accurancy)
 {
     return(FindNthRoot.NthRoot(numb, exp, accurancy));
 }
Ejemplo n.º 16
0
 public void FindRootExceptionTest(double num, int n, double precision)
 {
     Assert.Throws <ArgumentOutOfRangeException>(()
                                                 => FindNthRoot.FindRoot(num, n, precision));
 }
Ejemplo n.º 17
0
 public double FindRootTest(double num, int n, double precision) =>
 FindNthRoot.FindRoot(num, n, precision);
 public void NthRoot_WithNotValidAccurancy_ThrowsArgumentException()
 => FindNthRoot.NthRoot(9, 2, -1);
 public void NthRoot_WithNegativeRootExponent_ThrowsArgumentExceptio()
 => FindNthRoot.NthRoot(9, -2, 0.001);
Ejemplo n.º 20
0
        public void FindRootTest_Negative16and4and0001_06result()
        {
            double testValue = 0;

            testValue = FindNthRoot.FindRoot(-16, 4, 0.0001);
        }
        public void FindNthRootTestCase(double a, int n, double eps, double expected)
        {
            double actual = FindNthRoot.SqrtN(a, n, eps);

            Assert.AreEqual(actual, expected, eps);
        }
 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 void FindNthRoot_ThrowArgumentException(double a, int n, double eps)
 {
     Assert.Throws <ArgumentException>(() => FindNthRoot.SqrtN(a, n, eps));
 }
 public void NthRootNUnitTests_WithNotValidAccurancy_ThrowsArgumentException()
 {
     Assert.That(() => FindNthRoot.NthRoot(9, 2, -1),
                 Throws.ArgumentException.With.Message
                 .EqualTo("The accurancy is not valid"));
 }
Ejemplo n.º 25
0
        public void FindRoot_RootedValuePowerAccuracy_NthRoot(double value, double power, double accuracy, double actual)
        {
            var myRoot = FindNthRoot.FindRoot(value, power, accuracy);

            Assert.AreEqual(myRoot, actual, accuracy);
        }