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

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

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

            Assert.IsInstanceOf(type, calculator);
        }