protected void Button1_Click(object sender, EventArgs e) { // initializing the variables and helper classes int iNumber1; int iNumber2; MathsHelper helper = new MathsHelper(); //Validating the input provided if (txtInput1.Text != "" && txtInput2.Text != "") { try { //assigning the variables with the input provided iNumber1 = int.Parse(txtInput1.Text); iNumber2 = int.Parse(txtInput2.Text); //performing the addition int x = helper.Add(iNumber1, iNumber2); lblOutPut.Text = x.ToString(); } catch (Exception ex) { //returning the error to user lblOutPut.Text = "Error : " + ex.Message; } } else { lblOutPut.Text = "Input provided should be greater than zero"; } }
public void AddTestIncorrect() { MathsHelper helper = new MathsHelper(); int result = helper.Add(20, 10); Assert.AreEqual(40, result); }