Beispiel #1
0
        /// <summary>
        /// Run the program
        /// </summary>
        public void Run()
        {
            _logger.LogInformation("ConsoleApplication.Run");

            try
            {
                int[] arr1 = new int[MAX_LENGTH] {
                    2, 4, 6, 1, 3, 5
                };
                int[] arr2 = new int[MAX_LENGTH] {
                    3, 4, 2, 1, 6, 5
                };

                string result = _validateArray.ValidateArrayInput(arr1);
                Console.WriteLine($"Result: {result}");

                result = _validateArray.ValidateArrayInput(arr2);
                Console.WriteLine($"Result: {result}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                Console.WriteLine($"Exception: {ex}");
            }
            finally
            {
                Console.WriteLine("--- Press Any Key To Continue ---");
                Console.ReadKey(true);
            }
        }
        public void ValidateArrayInput_InvalidArrayLength_Test()
        {
            // Arrange
            int[] arr = new int[1] {
                1
            };

            // Act
            Action actual = () => _validateArray.ValidateArrayInput(arr);

            // Assert
            actual
            .Should()
            .Throw <ArgumentException>()
            .WithMessage("Input array must contain 6 elements (Parameter 'arr')");

            _logger.VerifyLog(LogLevel.Error, "Input array must contain 6 elements (Parameter 'arr')");
        }