Beispiel #1
0
        public void FirstTest(double firstValue, double secondValue, double expected)
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("doubleDivision");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result, 0.01);
        }
Beispiel #2
0
        public void AmountTest()
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("buttonAmount");
            double result = calculator.Calculate(5, 5);

            Assert.AreEqual(10, result);
        }
Beispiel #3
0
        public void FirstTest()
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("buttonDifference");
            double result = calculator.Calculate(6, 5);

            Assert.AreEqual(1, result);
        }
        public void FirstTest()
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("buttonMultiply");
            double result = calculator.Calculate(5, 5);

            Assert.AreEqual(25, result);
        }
Beispiel #5
0
 private void Click(object sender, EventArgs e)
 {
     try
     {
         string firstValueText             = textBox1.Text;
         string secondValueText            = textBox2.Text;
         double firstValue                 = Convert.ToDouble(firstValueText);
         double secondValue                = Convert.ToDouble(secondValueText);
         string buttonName                 = ((Button)sender).Name;
         ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator(buttonName);
         double result = calculator.Calculate(firstValue, secondValue);
         textBox3.Text = result.ToString();
     }
     catch (Exception exc)
     {
         textBox3.Text = "Ошибка";
     }
 }
Beispiel #6
0
        public ActionResult Index(double firstArgument, double secondArgument, string operation)
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstArgument, secondArgument);

            ViewBag.Result    = result;
            ViewBag.Operation = new SelectListItem[]
            {
                new SelectListItem()
                {
                    Value = "buttonAmount",
                    Text  = "Amount"
                },
                new SelectListItem()
                {
                    Value = "buttonDifference",
                    Text  = "Difference"
                }
            };
            return(View());
        }
Beispiel #7
0
        public void FirstTest(string name, Type type)
        {
            var calculator = CalculeteTwoFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }
Beispiel #8
0
        public void DivisionExeptionTest()
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("buttonDivision");

            Assert.Throws <Exception>(() => calculator.Calculate(5, 0));
        }