public ActionResult Index(double firstNumber, double secondNumber, string operation) { ITwoArgumentsCalculator calculator = TwoArgumentsCalculatorFactory.CreateCalculator(operation); ViewBag.result = calculator.Calculate(firstNumber, secondNumber); ViewBag.operations = operations; return(View()); }
public void TwoArgumentsButtonClick(object sender, EventArgs e) { try { Button clickedButton = (Button)sender; double number1 = Convert.ToDouble(Number1Field.Text); double number2 = Convert.ToDouble(Number2Field.Text); ITwoArgumentsCalculator calculator = TwoArgumentsCalculatorFactory.CreateCalculator(clickedButton.Text); double result = calculator.Calculate(number1, number2); ResultField.Text = result.ToString(); } catch (Exception exc) { ResultField.Text = exc.Message; } }
public void CalculateTest(string name, Type type) { var calculator = TwoArgumentsCalculatorFactory.CreateCalculator(name); Assert.IsInstanceOf(type, calculator); }