Exemplo n.º 1
0
        private static byte[] serializeBody <T>(T data, ContentType.ResourceFormat format, Func <T, byte[]> xmlSerializer, Func <T, byte[]> jsonSerializer)
        {
            var isBundle = data is Bundle;

            if (format == ContentType.ResourceFormat.Json)
            {
                return(jsonSerializer(data)); // FhirSerializer.SerializeBundleToJsonBytes(bundle);
            }
            else if (format == ContentType.ResourceFormat.Xml)
            {
                return(xmlSerializer(data));   // FhirSerializer.SerializeBundleToXmlBytes(bundle);
            }
            else
            {
                throw new ArgumentException("Cannot encode a batch into format " + format.ToString());
            }
        }
Exemplo n.º 2
0
        public static void AssertResourceResponseConformsTo(FhirClient client, ContentType.ResourceFormat format)
        {
            AssertValidResourceContentTypePresent(client);

            var type = client.LastResponseDetails.ContentType;

            if (ContentType.GetResourceFormatFromContentType(type) != format)
            {
                TestResult.Fail(String.Format("{0} is not acceptable when expecting {1}", type, format.ToString()));
            }
        }