/// <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); } }
public void UndefTest() { Type resultType = OneArgmumentFactory.CreateCalculator("Ass").GetType(); }
public void FactoryTest(Type type, string name) { Type resultType = OneArgmumentFactory.CreateCalculator(name).GetType(); Assert.AreEqual(type, resultType); }