Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public void WrongNameTest()
 {
     Assert.Throws <Exception>(() => OneFactory.CreateCalculator("button0"));
 }
Exemplo n.º 5
0
        public void CreateSqrtTest()
        {
            IOneCalculator calc = OneFactory.CreateCalculator("button8");

            Assert.IsInstanceOf(typeof(Sqrt), calc);
        }
Exemplo n.º 6
0
        public void CreateLnTest()
        {
            IOneCalculator calc = OneFactory.CreateCalculator("button7");

            Assert.IsInstanceOf(typeof(Ln), calc);
        }
Exemplo n.º 7
0
        public void SimpleTest(string name, Type type)
        {
            IOneCalculator calculator = OneFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }