コード例 #1
0
        public void TestDivideWithDivideByZeroException()
        {
            ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();
            int numerator   = 4;
            int denominator = 0;
            int actualResult;

            actualResult = exceptionHandlingCase.Divide(numerator, denominator);
        }
コード例 #2
0
        public void TestSmallestWithNullReferenceException()
        {
            ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();

            int[] arr = null;

            //Act
            int actualValue = exceptionHandlingCase.Smallest(arr);
        }
コード例 #3
0
        public void TestSmallestWithSizeZero()
        {
            ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();

            int[] arr           = { 12 };
            int   expectedValue = 12;

            //Act
            int actualValue = exceptionHandlingCase.Smallest(arr);

            //Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
コード例 #4
0
        public void TestSmallest()
        {
            ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();

            int[] arr           = { 12, 6, 8, 1, 7, 9, 23 };
            int   expectedValue = 1;

            //Act
            int actualValue = exceptionHandlingCase.Smallest(arr);

            //Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
コード例 #5
0
        public void TestSmallestWithNullValue()
        {
            try
            {
                ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();
                int[] arr = null;

                //Act
                int actualValue = exceptionHandlingCase.Smallest(arr);
            }
            catch (Exception e)
            {
                //Assert
                throw new AssertFailedException(e.Message, e);
            }
        }
コード例 #6
0
        public void TestDivide()
        {
            try
            {
                ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();
                int numerator   = 4;
                int denominator = 0;
                int actualResult;

                //Act
                actualResult = exceptionHandlingCase.Divide(numerator, denominator); // this will throw DivideByZeroException
            }
            catch (Exception e)
            {
                //Assert
                throw new AssertFailedException(e.Message, e);
            }
        }