Beispiel #1
0
        private void ButtonClick(object sender, EventArgs e)
        {
            string firstValueText             = TextBox1.Text;
            double firstValue                 = Convert.ToDouble(firstValueText);
            string secondValueText            = textBox2.Text;
            double secondValue                = Convert.ToDouble(secondValueText);
            string operation                  = ((Button)sender).Name;
            ITwoArgumentsCalculate calculator = TwoArgumentFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstValue, secondValue);

            label1.Text = result.ToString();
        }
Beispiel #2
0
        public void CalculateDivide2()
        {
            ITwoArgumentsCalculate calculator = TwoArgumentFactory.CreateCalculator("Divide");

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