public IActionResult GetAractionsByPropRef([FromRoute] GetAractionsByPropRefRequest request) { try { var validation_result = _getByPropRefValidator.Validate(request); if (validation_result.IsValid) { var usecase_result = _arrearsActionUsecase.GetByPropRef(request); return(Ok(usecase_result)); } return(BadRequest( new ErrorResponse(validation_result.Errors) )); } catch (NotFoundException ex) { return(NotFound(new ErrorResponse(ex.Message))); } catch (Exception ex) when(ex.InnerException != null) { return(StatusCode(500, new ErrorResponse(ex.Message, ex.InnerException.Message))); } catch (Exception ex) { return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public void Given_a_request_with_a_null_or_empty_or_whitespace_propertyRef__When_GetAractionsByPropRefRequestValidator_is_called__Then_it_returns_only_one_corresponding_error_message() { // arrange var request_empty = new GetAractionsByPropRefRequest() { PropertyRef = "" }; var request_whitespace = new GetAractionsByPropRefRequest() { PropertyRef = " " }; var request_null = new GetAractionsByPropRefRequest() { PropertyRef = null }; // act, assert _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request_empty) .WithErrorMessage(ErrorMessagesFormatter.FieldIsWhiteSpaceOrEmpty("PropertyRef")) .WithoutErrorMessage(ErrorMessagesFormatter.FieldIsNullMessage("PropertyRef")); _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request_whitespace) .WithErrorMessage(ErrorMessagesFormatter.FieldIsWhiteSpaceOrEmpty("PropertyRef")) .WithoutErrorMessage(ErrorMessagesFormatter.FieldIsNullMessage("PropertyRef")); _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request_null) .WithErrorMessage(ErrorMessagesFormatter.FieldIsNullMessage("PropertyRef")) .WithoutErrorMessage(ErrorMessagesFormatter.FieldIsWhiteSpaceOrEmpty("PropertyRef")); }
public void Given_a_request_with_a_null_propertyRef__When_GetAractionsByPropRefRequestValidator_is_called__Then_it_returns_correct_error_message() { // arrange var request = new GetAractionsByPropRefRequest() { PropertyRef = null }; // act, assert _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request).WithErrorMessage(ErrorMessagesFormatter.FieldIsNullMessage("PropertyRef")); }
public void Given_a_request_with_an_empty_or_whitespace_propertyRef__When_GetAractionsByPropRefRequestValidator_is_called__Then_it_returns_correct_error_message(string test_prop_ref) { // arrange var request = new GetAractionsByPropRefRequest() { PropertyRef = test_prop_ref }; // act, assert _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request).WithErrorMessage(ErrorMessagesFormatter.FieldIsWhiteSpaceOrEmpty("PropertyRef")); }
public void Given_a_request_with_a_null_propertyRef__When_GetAractionsByPropRefRequestValidator_is_called__Then_it_returns_an_error() { // arrange var request = new GetAractionsByPropRefRequest() { PropertyRef = null }; // act, assert _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request); }
public void Given_a_request_with_an_empty_or_whitespace_propertyRef__When_GetAractionsByPropRefRequestValidator_is_called__Then_it_returns_an_error(string test_prop_ref) { // arrange var request = new GetAractionsByPropRefRequest() { PropertyRef = test_prop_ref }; // act, assert _validatorUnderTest.ShouldHaveValidationErrorFor(r => r.PropertyRef, request); }
public GetAractionsByPropRefResponse GetByPropRef(GetAractionsByPropRefRequest request) { var gateway_result = _arrearsActionGateway.GetByPropRef(request.PropertyRef); return(new GetAractionsByPropRefResponse(request, gateway_result)); }