Esempio n. 1
0
 /// <inheritdoc />
 public override async Task <ValidateResourceResponse> ExecuteAsync(ValidateResourceRequest request)
 {
     try
     {
         var requestResource = this.FhirParser.Parse <Resource>(request.ResourceJson);
         return(new ValidateResourceResponse
         {
             Code = ResponseCode.Success, ValidationResult = FhirResourceValidator.Validate(requestResource).ToList()
         });
     }
     catch (FormatException exception)
     {
         return(new ValidateResourceResponse
         {
             Code = ResponseCode.Success,
             ValidationResult = new List <ValidationResult> {
                 new ValidationResult(exception.Message)
             },
             Exception = exception
         });
     }
     catch (Exception exception)
     {
         return(new ValidateResourceResponse {
             Code = ResponseCode.Failure, Exception = exception
         });
     }
 }
        public void GivenAResourceMissingId_WhenValidated_ThenInvalidFhirResourceExceptionShouldBeThrown()
        {
            var patient = new Patient();

            Assert.Throws <FhirResourceValidationException>(() => _fhirResourceValidator.Validate(patient));
        }