Esempio n. 1
0
        public void CallsCallbacks()
        {
            FhirClient client = new FhirClient(testEndpoint);

            bool           calledBefore = false;
            HttpStatusCode?status       = null;
            Resource       res          = null;

            Bundle.BundleEntryTransactionResponseComponent interaction = null;

            client.OnBeforeRequest += (sender, e) => calledBefore = true;
            client.OnAfterResponse += (sender, e) =>
            {
                res         = e.Resource;
                status      = e.RawResponse.StatusCode;
                interaction = e.Interaction;
            };

            client.Read <Patient>("Patient/1");
            Assert.IsTrue(calledBefore);
            Assert.IsNotNull(status);
            Assert.IsNotNull(res);
            Assert.IsTrue(res is Patient);
            Assert.IsTrue(interaction.GetBodyAsText().Contains("<Patient"));
            Assert.AreEqual("application/xml+fhir; charset=UTF-8", interaction.GetHeaders().Single(t => t.Item1 == "Content-Type").Item2);
        }
 public static IEnumerable <string> GetHeader(this Bundle.BundleEntryTransactionResponseComponent interaction, string header)
 {
     return(interaction.GetHeaders().Where(h => h.Item1 == header).Select(h => h.Item2));
 }