public void ZipApiException_WithErrorResponse_UsesErrorMessage()
        {
            var errorResponse = new ZipErrorResponse()
            {
                ErrorCode        = "TestErrorCode",
                IsValid          = false,
                Message          = "Operator is required",
                ValidationErrors = new ZipValidationError[]
                {
                    new ZipValidationError()
                    {
                        PropertyName  = "Operator",
                        ErrorMessages = new string[]
                        {
                            "Operator is required"
                        }
                    }
                }
            };

            var ex = new ZipApiException(errorResponse);

            Assert.AreEqual("Operator is required", ex.Message);
            Assert.IsNotNull(ex.Errors);
        }
        public void ZipApiException_WithErrorResponse_ConstructsWithErrorResponseAndInnerException()
        {
            var inner         = new InvalidOperationException("Test error");
            var errorResponse = new ZipErrorResponse()
            {
                ErrorCode        = "TestErrorCode",
                IsValid          = false,
                Message          = "Operator is required",
                ValidationErrors = new ZipValidationError[]
                {
                    new ZipValidationError()
                    {
                        PropertyName  = "Operator",
                        ErrorMessages = new string[]
                        {
                            "Operator is required"
                        }
                    }
                }
            };

            var ex = new ZipApiException(errorResponse, inner);

            Assert.AreEqual("Operator is required", ex.Message);
            Assert.IsNotNull(ex.Errors);
            Assert.AreEqual(inner, ex.InnerException);
        }
        public void ZipApiException_WithErrorResponse_ProvidesErrorCodeWithMessageFor400Response()
        {
            var inner         = new InvalidOperationException("Test error");
            var errorResponse = new ZipErrorResponse()
            {
                ErrorCode    = "AboveMaximumPreApprovalAmount",
                IsValid      = false,
                Message      = "The request is invalid",
                Type         = "https://partpay.net/errors/property-validation",
                ResponseCode = 400
            };

            var ex = new ZipApiException(errorResponse, inner);

            Assert.IsNotNull(ex.Errors);
            Assert.AreEqual("(AboveMaximumPreApprovalAmount) The request is invalid", ex.Message);
        }