コード例 #1
0
        protected void btnSubstract_Click(object sender, EventArgs e)
        {
            int num1   = Convert.ToInt32(txtNum1.Text);
            int num2   = Convert.ToInt32(txtNum2.Text);
            int result = CalculationOperation.Substract(num1, num2);

            lblResult.Text = result.ToString();
        }
コード例 #2
0
        public void Subtraction_test()
        {
            //Arrange Section- we initialize variables and set its values.
            int expectedResult = 20;
            int num1           = 24;
            int num2           = 4;

            //Act Section- We invoke the method we want to test.
            int actualResult = CalculationOperation.Substract(num1, num2);

            //Assert Section- we verify the method that we want to verify if the emthod behaves as per expected
            Assert.AreEqual(expectedResult, actualResult);
            Console.WriteLine("This is the test method for subtraction");
        }