public void FirstTest(double firstValue, double secondValue, double expected)
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("squareOfAmount");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result, 0.01);
        }
示例#2
0
        public void FirstTest()
        {
            ICalculateTwoArguments calculator = CalculeteTwoFactory.CreateCalculator("buttonDivision");
            double result = calculator.Calculate(5, 5);

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

            Assert.AreEqual(10, result);
        }
示例#4
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 = "Ошибка";
     }
 }
示例#5
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());
        }
示例#6
0
        public void FirstTest(string name, Type type)
        {
            var calculator = CalculeteTwoFactory.CreateCalculator(name);

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

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