Exemplo n.º 1
0
 protected void btnDiv_Click(object sender, EventArgs e)
 {
     try
     {
         float res = AppEngine.Divide(txbNum1.Text, txbNum2.Text);
         lblResult.Text = res.ToString();
     }
     catch (EngineException)
     {
         lblResult.Text = "Invalid input";
     }
 }
Exemplo n.º 2
0
        public void DivisionTest()
        {
            float res = AppEngine.Divide("45", "6");

            Assert.AreEqual(res, 7.5);
            res = AppEngine.Divide("-18", "-6");
            Assert.AreEqual(res, 3);
            Assert.Throws <EngineException>(() => AppEngine.Divide("13", "0"));
            Assert.Throws <EngineException>(() => AppEngine.Divide("", "6"));
            Assert.Throws <EngineException>(() => AppEngine.Divide("13", ""));
            Assert.Throws <EngineException>(() => AppEngine.Divide("1", "text"));
            Assert.Throws <EngineException>(() => AppEngine.Divide("text", "7"));
        }