Пример #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);
        }
Пример #2
0
        public void CalculateDegreeRootTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("degreeroot");
            double result = calculator.Calculate(25, 2);

            Assert.AreEqual(5, result);
        }
Пример #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);
        }
Пример #5
0
        public void CalculateTest(string name, Type type)

        {
            var calculator = TwoArgumentsFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }
Пример #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());
        }
Пример #7
0
        public void FirstTest()
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Multiply");
            double result = calculator.Calculate(5, 5);

            Assert.AreEqual(25, result);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #11
0
        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());
        }
Пример #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());
        }
Пример #13
0
        public void TestCalculate(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("DegreeRoot");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result);
        }
Пример #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));
        }
Пример #15
0
        public void MinCalculatorTest()
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Minimum");
            double result = calculator.Calculate(4, 2);

            Assert.AreEqual(2, result);
        }
Пример #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));
        }
Пример #17
0
        public void Calcpr(
            string name,
            Type type)
        {
            var actualResult = TwoArgumentsFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, actualResult);
        }
Пример #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());
        }
Пример #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);
        }
Пример #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;
     }
 }
Пример #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;
     }
 }
Пример #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);
     }
 }
Пример #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);
     }
 }
Пример #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)
            {
            }
        }
Пример #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("Некорректный ввод данных");
     }
 }
Пример #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;
            }
        }
Пример #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);
            }
        }
Пример #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;
     }
 }
Пример #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);
     }
 }
Пример #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 = "";
     }
 }