Ejemplo n.º 1
0
        public void GivenRequestValidationResponseIsValid__IsValidationErrorIsTrue()
        {
            //arrange
            //act
            var error = new RequestValidationResponse(true);

            //assert
            error.IsValid.Should().BeTrue();
            error.ValidationErrors.Should().BeNullOrEmpty();
        }
Ejemplo n.º 2
0
        public void WhenInstantiatingRequestValidationResponse_WithMessage_ThenValidationErrorsHas_ErrorMessage(string message)
        {
            //arrange
            //act
            var error = new RequestValidationResponse(message);

            //assert
            error.IsValid.Should().BeFalse();
            error.ValidationErrors.Should().NotBeNullOrEmpty();
            error.ValidationErrors[0].Message.Should().BeEquivalentTo(message);
        }
Ejemplo n.º 3
0
        public void GivenRequestValidationResponseIsNull_ApiErrorHas_IsValidationErrorIsTrue()
        {
            //arrange
            //act
            var error = new RequestValidationResponse(false);

            //assert
            error.IsValid.Should().BeFalse();
            error.ValidationErrors.Should().NotBeNullOrEmpty();
            error.ValidationErrors[0].Message.Should().BeEquivalentTo("Request is null or required sub objects are null");
        }
Ejemplo n.º 4
0
 public APIError(RequestValidationResponse validationResponse)
 {
     if (validationResponse == null)
     {
         IsValid = false;
     }
     else
     {
         IsValid          = validationResponse.IsValid;
         ValidationErrors = validationResponse.ValidationErrors;
     }
 }
Ejemplo n.º 5
0
        public void WhenRequestValidationResponse_ThenHasValidationErrors(string field, string message)
        {
            //arrange
            //act
            var error = new RequestValidationResponse(new ValidationResult(new List <ValidationFailure>
            {
                new ValidationFailure(field, message)
            }));

            //assert
            error.ValidationErrors.Should().NotBeNullOrEmpty();
            error.ValidationErrors[0].FieldName.Should().BeEquivalentTo(field);
            error.ValidationErrors[0].Message.Should().BeEquivalentTo(message);
        }
Ejemplo n.º 6
0
 public ExecuteWrapper(RequestValidationResponse validationResponse)
 {
     Error = new APIError(validationResponse);
 }
 public BadRequestException(RequestValidationResponse validationResponse)
 {
     StatusCode         = HttpStatusCode.BadRequest;
     ValidationResponse = validationResponse;
 }