Ejemplo n.º 1
0
 /// <summary>
 /// Event and exception handler for one-operand functoins
 /// </summary>
 /// <param name="sender">Pressed button name</param>
 private void ComputeOne(object sender, EventArgs e)
 {
     try
     {
         var    validator = new Validator();
         double argument  = validator.ValidateNumber(FirstValue.Text);
         string operation = ((Button)sender).Name;
         var    op        = OneArgmumentFactory.CreateCalculator(operation);
         double result    = op.Calculate(argument);
         Result.Text = Convert.ToString(result);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "You are a clayfish", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 2
0
 public void UndefTest()
 {
     Type resultType = OneArgmumentFactory.CreateCalculator("Ass").GetType();
 }
Ejemplo n.º 3
0
        public void FactoryTest(Type type, string name)
        {
            Type resultType = OneArgmumentFactory.CreateCalculator(name).GetType();

            Assert.AreEqual(type, resultType);
        }