protected void btnAdd_Click(object sender, EventArgs e) { try { float res = AppEngine.Add(txbNum1.Text, txbNum2.Text); lblResult.Text = res.ToString(); } catch (EngineException) { lblResult.Text = "Invalid input"; } }
public void AdditionTest() { float res = AppEngine.Add("45", "6"); Assert.AreEqual(res, 51); res = AppEngine.Add("-7", "-6"); Assert.AreEqual(res, -13); Assert.Throws <EngineException>(() => AppEngine.Add("", "6")); Assert.Throws <EngineException>(() => AppEngine.Add("13", "")); Assert.Throws <EngineException>(() => AppEngine.Add("1", "text")); Assert.Throws <EngineException>(() => AppEngine.Add("text", "7")); }