public ActionResult Calculate(double firstValue, double lastValue, string operation) { var calc = TwoArgumentsFatory.CreateCalculator(operation); double resultValue = calc.Calculate(firstValue, lastValue); return(View(resultValue)); }
private void Calculate_Click(object sender, EventArgs e) { try { double firstValue = Convert.ToDouble(textBox1.Text); double lastValue = Convert.ToDouble(textBox2.Text); var calc = TwoArgumentsFatory.CreateCalculator(((Button)sender).Name); double resultValue = calc.Calculate(firstValue, lastValue); textBox3.Text = resultValue.ToString(); } catch (Exception exception) { MessageBox.Show("Возникла ошибка: " + exception.Message); } }
public void CalculateTest(string name, Type type) { var calculator = TwoArgumentsFatory.CreateCalculator(name); Assert.IsInstanceOf(type, calculator); }