예제 #1
0
        public void DivideTest4()
        {
            //arrange-Declare actuals and expected
            string  numer    = "abc";
            string  denom    = "xyz";
            blClass b        = new blClass();
            var     expected = Assert.ThrowsException <FormatException>(() => b.Divide(numer.ToString(), denom.ToString()));

            Assert.AreEqual("only numbers", expected.Message);
        }
예제 #2
0
        public void DivideTest3()
        {
            //arrange-Declare actuals and expected
            int     numer    = 10;
            int     denom    = 0;
            blClass b        = new blClass();
            var     expected = Assert.ThrowsException <DivideByZeroException>(() => b.Divide(numer.ToString(), denom.ToString()));

            Assert.AreEqual("cannot divide by zero", expected.Message);
        }
예제 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            blClass b = new blClass();

            try
            {
                TextBox3.Text = b.Divide(TextBox1.Text, TextBox2.Text).ToString();
            }
            catch (DivideByZeroException E)
            {
                Response.Write(E.Message);
            }
        }
예제 #4
0
        public void DivideTest2()
        {
            //arrange-Declare actuals and expected
            int numer    = 0;
            int denom    = 2;
            int expected = 0;


            //act-call the method and pass the actuals as parameter
            blClass b      = new blClass();
            int     actual = b.Divide(numer.ToString(), denom.ToString());

            //assert-check whether actuals are matv=ching with expected
            Assert.AreEqual(expected, actual);
        }