Beispiel #1
0
        public void CalculateDivisionTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("div");
            double result = calculator.Calculate(26, 13);

            Assert.AreEqual(2, result);
        }
        public void CalculateDegreeRootTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("degreeroot");
            double result = calculator.Calculate(25, 2);

            Assert.AreEqual(5, result);
        }
Beispiel #3
0
        public void CalculateLogXYTest(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("logxy");
            double result = calculator.Calculate(8, 2);

            Assert.AreEqual(3, result);
        }
        public void TestCalculate(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("addition_of_two_numbers");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result);
        }
Beispiel #5
0
        public void CalculateTest(string name, Type type)

        {
            var calculator = TwoArgumentsFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }
Beispiel #6
0
        public ActionResult Index(double firstNumber, double secondNumber, string operation)
        {
            Calculator.TwoArguments.ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstNumber, secondNumber);

            ViewBag.Result    = result;
            ViewBag.Operation = new SelectListItem[]
            {
                new SelectListItem()
                {
                    Value = "multiply", Text = "multiply"
                },
                new SelectListItem()
                {
                    Value = "addition", Text = "addition"
                },
                new SelectListItem()
                {
                    Value = "substraction", Text = "substraction"
                },
                new SelectListItem()
                {
                    Value = "divide", Text = "divide"
                }
            };
            return(View());
        }
Beispiel #7
0
        public void FirstTest()
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Multiply");
            double result = calculator.Calculate(5, 5);

            Assert.AreEqual(25, result);
        }
Beispiel #8
0
        public void CalculateXDivYTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("xdivy");
            double result = calculator.Calculate(5, 2);

            Assert.AreEqual(2, result);
        }
Beispiel #9
0
        public void FirstTest(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Max");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result, 0.01);
        }
Beispiel #10
0
        public void CalculateTest(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Multiply");
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
        public ActionResult Index(double firstNumber, double secondNumber, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstNumber, secondNumber);

            ViewBag.Result    = result;
            ViewBag.Operation = new SelectListItem[]
            {
                new SelectListItem()
                {
                    Value = "Multiplication", Text = "Multiplication"
                },
                new SelectListItem()
                {
                    Value = "Plus", Text = "Plus"
                },
                new SelectListItem()
                {
                    Value = "Minus", Text = "Minus"
                },
                new SelectListItem()
                {
                    Value = "Division", Text = "Division"
                }
            };
            return(View());
        }
Beispiel #12
0
        public ActionResult Index(double firstArgument, double secondArgument, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstArgument, secondArgument);

            ViewBag.Result    = result;
            ViewBag.Operation = new SelectListItem[]
            {
                new SelectListItem()
                {
                    Value = "SolutionMulti", Text = "Multi"
                },
                new SelectListItem()
                {
                    Value = "SolutionPlus", Text = "Plus"
                },
                new SelectListItem()
                {
                    Value = "SolutionMinus", Text = "Minus"
                },
                new SelectListItem()
                {
                    Value = "SolutionDiv", Text = "Div"
                }
            };
            return(View());
        }
        public void TestCalculate(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("DegreeRoot");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result);
        }
Beispiel #14
0
        public ActionResult Calculate(double firstValue, double secondValue, string operation)
        {
            var    calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result     = calculator.ExecuteOperation(firstValue, secondValue);

            return(View(result));
        }
Beispiel #15
0
        public void MinCalculatorTest()
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Minimum");
            double result = calculator.Calculate(4, 2);

            Assert.AreEqual(2, result);
        }
Beispiel #16
0
        public ActionResult Calculator(double first, double second, string operation)
        {
            var    calc   = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calc.Calculate(first, second);

            return(View(result));
        }
Beispiel #17
0
        public void Calcpr(
            string name,
            Type type)
        {
            var actualResult = TwoArgumentsFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, actualResult);
        }
Beispiel #18
0
        public ActionResult Index(double firstNumber, double secondNumber, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);

            ViewBag.result     = calculator.Calculate(firstNumber, secondNumber);
            ViewBag.operations = operations;
            return(View());
        }
Beispiel #19
0
        private void ClickTwo(object sender, EventArgs e)
        {
            double first                       = Convert.ToDouble(textBox1.Text);
            double second                      = Convert.ToDouble(textBox2.Text);
            string calculationName             = ((Button)sender).Name;
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(calculationName);
            double result                      = calculator.Calculate(first, second);

            label1.Text = Convert.ToString(result);
        }
Beispiel #20
0
 private void btn_Click(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = Convert.ToDouble(textBox1.Text);
         double secondArgument = Convert.ToDouble(textBox2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstArgument, secondArgument);
         textBox3.Text = result.ToString(CultureInfo.InvariantCulture);
     }
     catch (Exception exception)
     {
         textBox3.Text = exception.Message;
     }
 }
Beispiel #21
0
 private void button_Click(object sender, EventArgs e)
 {
     try
     {
         double firstNumber  = Convert.ToDouble(textNumber1.Text);
         double secondNumber = Convert.ToDouble(textNumber2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstNumber, secondNumber);
         textResult.Text = result.ToString();
     }
     catch (Exception ex)
     {
         textResult.Text = "mistake: " + ex.Message;
     }
 }
Beispiel #22
0
 private void act_Click(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = Convert.ToDouble(textBox1.Text);
         double secondArgument = Convert.ToDouble(textBox2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstArgument, secondArgument);
         label1.Text = Convert.ToString(result);
     }
     catch (Exception exc)
     {
         MessageBox.Show("ошибка: " + exc.Message);
     }
 }
Beispiel #23
0
 private void TwoArgumentButtonClick(object sender, EventArgs e)
 {
     try
     {
         double first  = Convert.ToDouble(Input1.Text);
         double second = Convert.ToDouble(Input2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(first, second);
         Result.Text = Convert.ToString(result);
     }
     catch (Exception exc)
     {
         MessageBox.Show("Возникла ошибка:" + exc.Message);
     }
 }
Beispiel #24
0
        private void CalculateClick(object sender, EventArgs e)
        {
            try
            {
                double firstNumber  = Convert.ToDouble(InputVar1.Text);
                double secondNumber = Convert.ToDouble(InputVar2.Text);

                var    calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
                double result     = calculator.Calculate(firstNumber, secondNumber);

                OutputVar.Text = result.ToString();
            }
            catch (Exception exc)
            {
            }
        }
Beispiel #25
0
 private void ButtonClick(object sender, EventArgs e)
 {
     try
     {
         double firstNumber  = Convert.ToDouble(TextBoxNumber1.Text);
         double secondNumber = Convert.ToDouble(TextBoxNumber2.Text);
         string buttonName   = ((Button)sender).Name;
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(buttonName);
         double result = calculator.Calculate(firstNumber, secondNumber);
         TextBoxResult.Text = result.ToString();
     }
     catch (Exception exc)
     {
         throw new Exception("Некорректный ввод данных");
     }
 }
Beispiel #26
0
        private void Calculate(object sender, EventArgs e)
        {
            try
            {
                double firstArgument  = Convert.ToDouble(textBox1.Text);
                double secondArgument = Convert.ToDouble(textBox2.Text);

                ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
                var result = calculator.Calculate(firstArgument, secondArgument);
                textBox3.Text = result.ToString();
            }
            catch (Exception exc)
            {
                textBox3.Text = "Error:" + exc.Message;
            }
        }
Beispiel #27
0
        private void Label1_Click(object sender, EventArgs e)
        {
            double      firstArgument  = Convert.ToDouble(firstValue.Text);
            double      secondArgument = Convert.ToDouble(secondValue.Text);
            ICalculator calculator     = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);

            try
            {
                var result = calculator.Calculate(firstArgument, secondArgument);
                Result.Text = result.ToString();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK);
            }
        }
Beispiel #28
0
 private void Click(object sender, EventArgs e)
 {
     try
     {
         string firstValueText              = textBox1.Text;
         double firstValue                  = Convert.ToDouble(firstValueText);
         string secondValueText             = textBox2.Text;
         double secondValue                 = Convert.ToDouble(secondValueText);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstValue, secondValue);
         Output.Text = result.ToString();
     }
     catch (Exception exc)
     {
         Output.Text = exc.Message;
     }
 }
Beispiel #29
0
 private void ClickMain(object sender, EventArgs e)
 {
     try
     {
         string firstValueText              = textBox1.Text;
         double firstValue                  = Convert.ToDouble(firstValueText);
         string secondValueText             = textBox3.Text;
         double secondValue                 = Convert.ToDouble(secondValueText);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstValue, secondValue);
         textBox2.Text = result.ToString();
     }
     catch (Exception TwoArgumentsException)
     {
         MessageBox.Show("Неверное выражение" + TwoArgumentsException);
     }
 }
Beispiel #30
0
 private void CalculateTwoArguments(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = double.Parse(FirstArgumentTextBox.Text);
         double secondArgument = double.Parse(SecondArgumentTextBox.Text);
         double result         = 0;
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         result             = calculator.Calculate(firstArgument, secondArgument);
         ResultTextBox.Text = result.ToString();
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK);
         FirstArgumentTextBox.Text  = "";
         SecondArgumentTextBox.Text = "";
     }
 }