コード例 #1
0
        public void ReverseArray_ReturnsReversedArray()
        {
            string[] array          = { "1", "2", "3", "4", "5" };
            int[]    expectedResult = { 5, 4, 3, 2, 1 };

            var arrayManipulationService = new ArrayManipulationService();
            var result = arrayManipulationService.ReverseArray(array);

            Assert.Equal(expectedResult, result);
        }
コード例 #2
0
        public void ReverseArray_WhenInputArrayIsEmpty_ReturnsEmptyArray()
        {
            string[] array          = {};
            int[]    expectedResult = {};

            var arrayManipulationService = new ArrayManipulationService();
            var result = arrayManipulationService.ReverseArray(array);

            Assert.Equal(expectedResult, result);
        }
コード例 #3
0
        public void ReverseArray_WhenElementIsNotNumber_ThrowsException()
        {
            string[] array        = { "1", "InvalidValue", "3", "4", "5" };
            int[]    result       = null;
            var      errorMessage = "";

            try
            {
                var arrayManipulationService = new ArrayManipulationService();
                result = arrayManipulationService.ReverseArray(array);
            }
            catch (Exception error)
            {
                errorMessage = error.Message;
            }

            Assert.Null(result);
            Assert.Equal("NaN", errorMessage);
        }