Ejemplo n.º 1
0
 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";
     }
 }
Ejemplo n.º 2
0
        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"));
        }