public void CalculateTest(double arOne, double arTwo, double expected)
        {
            var calculator   = new Power();
            var actualResult = calculator.Calculate(arOne, arTwo);

            Assert.AreEqual(expected, actualResult);
        }
Beispiel #2
0
        public void CalculateTest()
        {
            IOneArgumentCalculator calculator = new Power();
            double result = calculator.Calculate(1);

            Assert.AreEqual(2.71, result, 0.01);
        }
Beispiel #3
0
        public void TestPower(double firstArgument, double secondArgument, double output)
        {
            var calculator = new Power();
            var testResult = calculator.Calculate(firstArgument, secondArgument);

            Assert.AreEqual(output, testResult, 0.0000001);
        }
        public void Calculate(double firstInput, double secondInput, double output)
        {
            var calculator = new Power();
            var testResult = calculator.Calculate(firstInput, secondInput);
            var result     = output;

            Assert.AreEqual(testResult, result);
        }
Beispiel #5
0
        public void TestPowerNegativeExp()
        {
            Power power = new Power();

            power.Base     = 2;
            power.Exponent = -2;
            var result = power.Calculate();

            Assert.AreEqual(0.25, result, $"{power.Base} multiplied to the {power.Exponent} power resulted in {result}");
        }
Beispiel #6
0
        public void TestPowerExp0()
        {
            Power power = new Power();

            power.Base     = 2.0;
            power.Exponent = 0.0;
            var result = power.Calculate();

            Assert.AreEqual(1, result, $"{power.Base} multiplied to the {power.Exponent} power resulted in {result}");
        }
Beispiel #7
0
        public void TestPowerShouldFail()
        {
            Power power = new Power();

            power.Base     = 2;
            power.Exponent = 3;
            var result = power.Calculate();

            Assert.AreEqual(4, result, $"{power.Base} multiplied to the {power.Exponent} power resulted in {result}");
        }
Beispiel #8
0
        void TestPower(double Base, double Exponent)
        {
            Power power = new Power();

            power.Base     = Base;
            power.Exponent = Exponent;

            var aPower = power.Calculate();

            Debug.WriteLine($"{Base} to the {Exponent} power resulted in {aPower}");
        }
Beispiel #9
0
        public void Execute()
        {
            IMessagePrinter printer = uiFactory.CreateMessagePrinter();
            List <String>   args    = new List <string>();

            args.Add("Error");
            args.Add("Number");
            args.Add("Power");
            IDialogView   dialog        = uiFactory.CreateDialogView();
            List <string> results       = dialog.ShowSelectionDialog(args);
            double        number        = 0;
            double        error         = 0;
            double        power         = 0;
            bool          parsingfailed = false;

            if (!double.TryParse(results.ElementAt(0), out error))
            {
                parsingfailed = true;
                printer.Print("First input is not a number");
            }
            if (!double.TryParse(results.ElementAt(1), out number))
            {
                parsingfailed = true;
                printer.Print("Second input is not a number");
            }
            if (!double.TryParse(results.ElementAt(1), out power))
            {
                parsingfailed = true;
                printer.Print("Third input is not a number");
            }
            if (!parsingfailed)
            {
                ITaylorExpansion exp    = new Power(error, number, power);
                Result           result = exp.Calculate();
                if (result.Exist)
                {
                    printer.Print("Answer " + result.Answer);
                }
                else
                {
                    printer.Print("Answer does not exist");
                }
            }
        }
Beispiel #10
0
 public void NMore100()
 {
     Assert.AreEqual(Power.Calculate(2, 200), "Error: n must be in [1..100]");
 }
Beispiel #11
0
 public void NLess1()
 {
     Assert.AreEqual(Power.Calculate(10, -1), "Error: n must be in [1..100]");
 }
Beispiel #12
0
 public void NMore1Less100()
 {
     Assert.AreNotEqual(Power.Calculate(5, 2), "Error: n must be in [1..100]");
 }
Beispiel #13
0
 public void XMore0Less999()
 {
     Assert.AreNotEqual(Power.Calculate(340, 5), "Error: x must be in [0..999]");
 }
Beispiel #14
0
 public void XMore999()
 {
     Assert.AreEqual(Power.Calculate(1000, 5), "Error: x must be in [0..999]");
 }
Beispiel #15
0
 public void XLessThan0()
 {
     Assert.AreEqual(Power.Calculate(-100, 5), "Error: x must be in [0..999]");
 }