private void OneClick(object sender, EventArgs e) { try { double firstArgument = Convert.ToDouble(textBox1.Text); IOneCalculator calculator = OneFactory.CreateCalculator(((Button)sender).Name); double result = calculator.Calculate(firstArgument); label2.Text = result.ToString(); } catch (Exception ex) { MessageBox.Show("Ошибка! " + ex.Message); } }
private void ClickOne(object sender, EventArgs e) { try { double firstArgument = Convert.ToDouble(textBox1.Text); IOneArgumentCalculator calculator = OneFactory.CreateCalculator((((Button)sender).Name)); double result = calculator.Calculate(firstArgument); textBox3.Text = result.ToString(); } catch (Exception single) { textBox3.Text = single.Message; } }
private void OneCalculate(object sender, EventArgs e) { try { double firstArg = Convert.ToDouble(textBox1.Text); IOneCalculator calc = OneFactory.CreateCalculator(((Button)sender).Name); var result = calc.Doit(firstArg); label1.Text = result.ToString(); } catch (Exception ex) { MessageBox.Show("Ошибка: " + ex.Message); } }
public void WrongNameTest() { Assert.Throws <Exception>(() => OneFactory.CreateCalculator("button0")); }
public void CreateSqrtTest() { IOneCalculator calc = OneFactory.CreateCalculator("button8"); Assert.IsInstanceOf(typeof(Sqrt), calc); }
public void CreateLnTest() { IOneCalculator calc = OneFactory.CreateCalculator("button7"); Assert.IsInstanceOf(typeof(Ln), calc); }
public void SimpleTest(string name, Type type) { IOneCalculator calculator = OneFactory.CreateCalculator(name); Assert.IsInstanceOf(type, calculator); }