public static void AddErrorCode__Should_not_throw___When_all_parameters_are_valid()
        {
            // Arrange
            var errorCode = " a good code ";
            var exception = new ArgumentException();

            // Act
            var actual = Record.Exception(() => exception.AddErrorCode(errorCode));

            // Assert
            actual.Should().BeNull();
        }
        public static void AddErrorCode__Should_throw_ArgumentNullException___When_parameter_errorCode_is_null()
        {
            // Arrange
            var exception = new ArgumentException();

            // Act
            var actual = Record.Exception(() => exception.AddErrorCode(null));

            // Assert
            actual.Should().BeOfType <ArgumentNullException>();
            actual.Message.Should().Contain("errorCode");
        }
        public static void AddErrorCode__Should_throw_ArgumentNullException___When_parameter_dataKeyForErrorCodesVector_is_null()
        {
            // Arrange
            var errorCode = A.Dummy <string>();
            var exception = new ArgumentException();

            // Act
            var actual = Record.Exception(() => exception.AddErrorCode(errorCode, dataKeyForErrorCodesVector: null));

            // Assert
            actual.Should().BeOfType <ArgumentNullException>();
            actual.Message.Should().Contain("dataKeyForErrorCodesVector");
        }
        public static void AddErrorCode__Should_throw_ArgumentException___When_parameter_dataKeyForErrorCode_is_white_space()
        {
            // Arrange
            var errorCode = A.Dummy <string>();
            var exception = new ArgumentException();

            // Act
            var actual = Record.Exception(() => exception.AddErrorCode(errorCode, dataKeyForErrorCode: "  \r\n  "));

            // Assert
            actual.Should().BeOfType <ArgumentException>();
            actual.Message.Should().Contain("dataKeyForErrorCode");
            actual.Message.Should().Contain("white space");
        }
        public static void GetErrorCodesVector___Should_return_error_code_of_exception___When_error_code_was_added_to_exception_and_no_InnerException_nor_InnerExceptions()
        {
            // Arrange,
            var exception = new ArgumentException();
            var errorCode = A.Dummy <string>();

            exception.AddErrorCode(errorCode);

            // Act
            var actual = exception.GetErrorCodesVector();

            // Assert
            actual.Should().Be(errorCode);
        }
        public static void GetErrorCode___Should_return_error_code___When_error_code_was_added_to_exception()
        {
            // Arrange,
            var exception = new ArgumentException();
            var expected  = "this-is-an-ERROR_CODE";

            exception.AddErrorCode(expected);

            // Act
            var actual = exception.GetErrorCode();

            // Assert
            actual.Should().Be(expected);
        }
        public static void GetErrorCodesVector___Should_return_error_code_of_exception___When_error_code_was_added_to_and_retrieved_from_exception_using_custom_dataKeyForErrorCodesVector()
        {
            // Arrange,
            var exception = new ArgumentException();
            var dataKeyForErrorCodesVector = A.Dummy <string>();
            var errorCode = A.Dummy <string>();

            exception.AddErrorCode(errorCode, dataKeyForErrorCodesVector: dataKeyForErrorCodesVector);

            // Act
            var actual = exception.GetErrorCodesVector(dataKeyForErrorCodesVector);

            // Assert
            actual.Should().Be(errorCode);
        }
        public static void GetErrorCode___Should_return_error_code___When_error_code_was_added_to_exception_and_retrieved_from_exception_using_custom_dataKeyForErrorCode()
        {
            // Arrange,
            var exception           = new ArgumentException();
            var dataKeyForErrorCode = A.Dummy <string>();
            var expected            = "this-is-an-ERROR_CODE";

            exception.AddErrorCode(expected, dataKeyForErrorCode: dataKeyForErrorCode);

            // Act
            var actual = exception.GetErrorCode(dataKeyForErrorCode);

            // Assert
            actual.Should().Be(expected);
        }
        public static void AddErrorCode__Should_throw_ArgumentOutOfRangeException___When_parameter_dataKeyForErrorCodesVector_equals_dataKeyForErrorCode()
        {
            // Arrange
            var errorCode = A.Dummy <string>();
            var exception = new ArgumentException();
            var key       = A.Dummy <string>();

            // Act
            var actual = Record.Exception(() => exception.AddErrorCode(errorCode, dataKeyForErrorCode: key, dataKeyForErrorCodesVector: key));

            // Assert
            actual.Should().BeOfType <ArgumentOutOfRangeException>();
            actual.Message.Should().Contain("dataKeyForErrorCode cannot equal dataKeyForErrorCodesVector");
            actual.Message.Should().Contain(key);
        }
        public static void AddErrorCode__Should_throw_ArgumentException___When_parameter_exception_Data_already_contains_ExceptionDataKeyForErrorCodesVector()
        {
            // Arrange
            var errorCode = " a good code";
            var exception = new ArgumentException();

            exception.Data[ErrorCodeConstants.ExceptionDataKeyForErrorCodesVector] = A.Dummy <object>();

            // Act
            var actual = Record.Exception(() => exception.AddErrorCode(errorCode));

            // Assert
            actual.Should().BeOfType <ArgumentException>();
            actual.Message.Should().Contain("exception.Data.Keys");
            actual.Message.Should().Contain(ErrorCodeConstants.ExceptionDataKeyForErrorCodesVector);
        }