protected void Button1_Click(object sender, EventArgs e) { BLClass B = new BLClass(); try { txtresult.Text = (B.Divide(txtnum.Text, txtdenom.Text)).ToString(); } catch (DivideByZeroException E) { Response.Write(E.Message); } catch (FormatException E) { Response.Write(E.Message); } //try //{ // txtresult.Text = (int.Parse(txtnum.Text) / int.Parse(txtdenom.Text)).ToString(); //} //catch(DivideByZeroException e1) //{ // Response.Write(e1.Message); //} }
public void DivideTest4() { BLClass B = new BLClass(); var ex = Assert.ThrowsException <FormatException>(() => B.Divide("abc", "xyz")); Assert.AreEqual("only numbers", ex.Message); }
public void DivideTest2() { //Arrange - Declare Actuals and Expected int numerator = 0; int denominator = 2; int actual = 0; int expected = 0; //Act - call the method and pass the actuals as parameters BLClass B = new BLClass(); actual = B.Divide(numerator.ToString(), denominator.ToString()); // Assert - check whether Actuals are matching with expected Assert.AreEqual(expected, actual); }
protected void Button1_Click(object sender, EventArgs e) { BLClass BL = new BLClass(); try { txtResult.Text = (BL.Divide(txtNumerator.Text, txtDenominator.Text)).ToString(); } catch (DivideByZeroException E) { Response.Write(E.Message); } catch (FormatException E) { Response.Write(E.Message); } finally { } }
public void DivideTest3() { //Arrange - Declare Actuals and Expected int numerator = 10; int denominator = 0; BLClass B = new BLClass(); var expected = Assert.ThrowsException <DivideByZeroException>(() => B.Divide(numerator.ToString(), denominator.ToString())); Assert.AreEqual("Cannot divide by zero", expected.Message); }