Beispiel #1
0
        public void TestDivideWithDivideByZeroException()
        {
            ExceptionHandlingCase exceptionHandlingCase = new ExceptionHandlingCase();
            int numerator   = 4;
            int denominator = 0;
            int actualResult;

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

            int[] arr = null;

            //Act
            int actualValue = exceptionHandlingCase.Smallest(arr);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }