Beispiel #1
0
        public void ValidCreateReferralRequestValidationReturnsNoErrorsOnValidation()
        {
            var createReferralRequest = TestHelpers.CreateNewMashReferralRequest();
            var validator             = new CreateReferralRequestValidator();

            var validationResponse = validator.Validate(createReferralRequest);

            validationResponse.IsValid.Should().Be(true);
        }
        public IActionResult CreateReferral([FromBody] CreateReferralRequest request)
        {
            var validator  = new CreateReferralRequestValidator();
            var validation = validator.Validate(request);

            if (!validation.IsValid)
            {
                return(BadRequest(validation.ToString()));
            }

            _mashReferralUseCase.CreateNewMashReferral(request);

            return(CreatedAtAction(nameof(CreateReferral), "Successfully created new contact referral"));
        }
Beispiel #3
0
        public void CreateReferralRequestValidationReturnsErrorsWhenAnyPropertyIsEmpty()
        {
            var badRequests = new List <(CreateReferralRequest, string)>()
            {
                (TestHelpers.CreateNewMashReferralRequest(""), "Referrer must have at least one character"),
                (TestHelpers.CreateNewMashReferralRequest(requestedSupport: ""), "Requested support must have at least one character"),
                (TestHelpers.CreateNewMashReferralRequest(referralUri: ""), "Referral document url must have at least one character"),
            };

            var validator = new CreateReferralRequestValidator();

            foreach (var(request, expectedErrorMessage) in badRequests)
            {
                var validationResponse = validator.Validate(request);

                validationResponse.IsValid.Should().Be(false);
                validationResponse.ToString().Should().Be(expectedErrorMessage);
            }
        }