public BaseExceptionMiddlewareTests()
        {
            _correlationId = Guid.NewGuid().ToString();

            _fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();
            _fhirRequestContextAccessor.FhirRequestContext.CorrelationId.Returns(_correlationId);
            _formatParametersValidator = Substitute.For <IFormatParametersValidator>();

            _context = new DefaultHttpContext();

            // The default context has a null stream, so give it a memory stream instead
            _context.Response.Body = new MemoryStream();
        }
        public BaseExceptionMiddleware(
            RequestDelegate next,
            ILogger <BaseExceptionMiddleware> logger,
            IFhirRequestContextAccessor fhirRequestContextAccessor,
            IFormatParametersValidator parametersValidator)
        {
            EnsureArg.IsNotNull(next, nameof(next));
            EnsureArg.IsNotNull(logger, nameof(logger));
            EnsureArg.IsNotNull(fhirRequestContextAccessor, nameof(fhirRequestContextAccessor));
            EnsureArg.IsNotNull(parametersValidator, nameof(parametersValidator));

            _next   = next;
            _logger = logger;
            _fhirRequestContextAccessor = fhirRequestContextAccessor;
            _parametersValidator        = parametersValidator;
        }
        public ValidateFormatParametersAttribute(IFormatParametersValidator parametersValidator)
        {
            EnsureArg.IsNotNull(parametersValidator, nameof(parametersValidator));

            _parametersValidator = parametersValidator;
        }