private void Calculate(object sender, EventArgs e) { try { string firstValue = textBox1.Text; string secondValue = textBox2.Text; double first = Convert.ToDouble(firstValue); double second = Convert.ToDouble(secondValue); double third; ICalculate calculate = Calculaterfactory.CreatCalculator(((Button)sender).Name); third = calculate.Calculate(first, second); Rez.Text = third.ToString(); } catch (Exception ex) { MessageBox.Show("произошла ошибка: " + ex.Message); } }
public void CreatCalculatorTest(string name, Type type) { ICalculate calculate = Calculaterfactory.CreatCalculator(name); Assert.IsInstanceOf(type, calculate); }