Beispiel #1
0
 /// <summary>
 /// Arithmetic operation with two of arguments from two of text box.
 /// </summary>
 /// <param name="sender">
 /// Pressing button activates the event
 /// </param>
 /// <param name="e">
 /// Arguments are being sended
 /// </param>
 private void BinaryOperation(object sender, EventArgs e)
 {
     try
     {
         var calculatorName = ((Button)sender).Name.Substring(6);
         var calculator     = BinaryFactory.CreateBinaryCalculator(calculatorName);
         ValidateAndConvert validateConvert = new ValidateAndConvert();
         var firstArgument  = validateConvert.doubleValidate(txtFirst.Text);
         var secondArgument = validateConvert.doubleValidate(txtSecond.Text);
         txtResult.Text = calculator.Calculate(firstArgument, secondArgument).ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }
Beispiel #2
0
        public void BinaryFactoryTest(Type type, string name)
        {
            Type resultType = BinaryFactory.CreateBinaryCalculator(name).GetType();

            Assert.AreEqual(type, resultType);
        }