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

            Assert.AreEqual(type, resultType);
        }