public FormatterConfigurationTests() { var serializer = new FhirJsonSerializer(); _htmlOutputFormatter = new HtmlOutputFormatter(serializer, NullLogger <HtmlOutputFormatter> .Instance, new NarrativeHtmlSanitizer(NullLogger <NarrativeHtmlSanitizer> .Instance), ArrayPool <char> .Shared); _fhirJsonOutputFormatter = new FhirJsonOutputFormatter(serializer, NullLogger <FhirJsonOutputFormatter> .Instance, ArrayPool <char> .Shared); _configuration = new FormatterConfiguration( Options.Create(_featureConfiguration), new TextInputFormatter[] { _fhirJsonInputFormatter, _fhirXmlInputFormatter }, new TextOutputFormatter[] { _htmlOutputFormatter, _fhirJsonOutputFormatter, _fhirXmlOutputFormatter }); _options = new MvcOptions(); _options.Filters.Add(new UnsupportedContentTypeFilter()); }
private bool CanRead(Type modelType, string contentType) { var formatter = new FhirJsonOutputFormatter(new FhirJsonSerializer(), Deserializers.ResourceDeserializer, new NullLogger <FhirJsonOutputFormatter>(), ArrayPool <char> .Shared, new BundleSerializer()); var defaultHttpContext = new DefaultHttpContext(); defaultHttpContext.Request.ContentType = contentType; var result = formatter.CanWriteResult( new OutputFormatterWriteContext( new DefaultHttpContext(), Substitute.For <Func <Stream, Encoding, TextWriter> >(), modelType, new Observation())); return(result); }