示例#1
0
        //This test verifies that an error is returned if a number is divided by zero
        public void CheckDivisionError()
        {
            //Arrange
            var          num1      = "20";
            var          num2      = "0";
            CalcOperator operation = new CalcOperator();

            //Assert
            Assert.Throws <DivideByZeroException>(
                () => operation.Divide(num1, num2)
                );
        }
示例#2
0
        //This test that the Divide method outputs correctly
        public void DivideOperator()
        {
            //Arrange

            /*The num1 and num2 is a string because the Divide method receives a string
             * as input and parses it into a double */
            var num1 = "15";
            var num2 = "16";

            /*creates an instance of the CalcOperator class to enable the test access the Divide
             * method*/
            var operation = new CalcOperator();
            var expected  = 0.9375;

            //Act
            var actual = operation.Divide(num1, num2);


            //Assert
            Assert.Equal(actual, expected);
        }