public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); client.ParserSettings.AllowUnrecognizedEnums = true; var entry = client.Conformance(); Assert.IsNotNull(entry.Text); Assert.IsNotNull(entry); Assert.IsNotNull(entry.FhirVersion); // Assert.AreEqual("Spark.Service", c.Software.Name); // This is only for ewout's server Assert.AreEqual(Conformance.RestfulConformanceMode.Server, entry.Rest[0].Mode.Value); Assert.AreEqual("200", client.LastResult.Status); entry = client.Conformance(SummaryType.True); Assert.IsNull(entry.Text); // DSTU2 has this property as not include as part of the summary (that would be with SummaryType.Text) Assert.IsNotNull(entry); Assert.IsNotNull(entry.FhirVersion); Assert.AreEqual(Conformance.RestfulConformanceMode.Server, entry.Rest[0].Mode.Value); Assert.AreEqual("200", client.LastResult.Status); Assert.IsNotNull(entry.Rest[0].Resource, "The resource property should be in the summary"); Assert.AreNotEqual(0, entry.Rest[0].Resource.Count, "There is expected to be at least 1 resource defined in the conformance statement"); Assert.IsTrue(entry.Rest[0].Resource[0].Type.HasValue, "The resource type should be provided"); Assert.AreEqual(0, entry.Rest[0].Operation.Count, "operations should not be listed in the summary"); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); var entry = client.Conformance(); Assert.IsNotNull(entry); // Assert.AreEqual("Spark.Service", c.Software.Name); // This is only for ewout's server Assert.AreEqual(Conformance.RestfulConformanceMode.Server, entry.Rest[0].Mode.Value); Assert.AreEqual(HttpStatusCode.OK.ToString(), client.LastResult.Status); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); var entry = client.Conformance(); Assert.IsNotNull(entry); // Assert.AreEqual("Spark.Service", c.Software.Name); // This is only for ewout's server Assert.AreEqual(Conformance.RestfulConformanceMode.Server, entry.Rest[0].Mode.Value); Assert.AreEqual("200", client.LastResult.Status); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); Conformance c = client.Conformance().Resource; Assert.IsNotNull(c); Assert.AreEqual("HL7Connect", c.Software.Name); Assert.AreEqual(Conformance.RestfulConformanceMode.Server, c.Rest[0].Mode.Value); Assert.AreEqual(ContentType.XML_CONTENT_HEADER, client.LastResponseDetails.ContentType.ToLower()); Assert.AreEqual(HttpStatusCode.OK, client.LastResponseDetails.Result); }
public void FhirVersionIsChecked() { var testEndpointDSTU2 = new Uri("http://spark-dstu2.furore.com/fhir"); var testEndpointDSTU1 = new Uri("http://spark.furore.com/fhir"); var testEndpointDSTU12 = new Uri("http://fhirtest.uhn.ca/baseDstu1"); var testEndpointDSTU22 = new Uri("http://fhirtest.uhn.ca/baseDstu2"); var testEndpointDSTU23 = new Uri("http://fhir3.healthintersections.com.au/open"); var client = new FhirClient(testEndpointDSTU1); client.ParserSettings.AllowUnrecognizedEnums = true; Conformance p; try { client = new FhirClient(testEndpointDSTU23, verifyFhirVersion: true); client.ParserSettings.AllowUnrecognizedEnums = true; p = client.Conformance(); } catch (NotSupportedException) { //Client uses 1.0.1, server states 1.0.0-7104 } client = new FhirClient(testEndpointDSTU23); client.ParserSettings.AllowUnrecognizedEnums = true; // p = client.Conformance(); // The STU3 server conformance resource is now called CapabilityStatement. //client = new FhirClient(testEndpointDSTU2); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); //client = new FhirClient(testEndpointDSTU22, verifyFhirVersion:true); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); client = new FhirClient(testEndpointDSTU12); client.ParserSettings.AllowUnrecognizedEnums = true; try { p = client.Conformance(); Assert.Fail("Getting DSTU1 data using DSTU2 parsers should have failed"); } catch (Exception) { // OK } }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); var entry = client.Conformance(); var c = entry.Resource; Assert.IsNotNull(c); // Assert.AreEqual("Spark.Service", c.Software.Name); // This is only for ewout's server Assert.AreEqual(Conformance.RestfulConformanceMode.Server, c.Rest[0].Mode.Value); Assert.AreEqual(HttpStatusCode.OK, client.LastResponseDetails.Result); // Does't currently work on Grahame's server Assert.AreEqual(ContentType.XML_CONTENT_HEADER, client.LastResponseDetails.ContentType.ToLower()); }
public void FhirVersionIsChecked() { var testEndpointDSTU2 = new Uri("http://spark-dstu2.furore.com/fhir"); var testEndpointDSTU1 = new Uri("http://spark.furore.com/fhir"); var testEndpointDSTU12 = new Uri("http://fhirtest.uhn.ca/baseDstu1"); var testEndpointDSTU22 = new Uri("http://fhirtest.uhn.ca/baseDstu2"); var testEndpointDSTU23 = new Uri("http://fhir-dev.healthintersections.com.au/open"); var client = new FhirClient(testEndpointDSTU1); Conformance p; try { client = new FhirClient(testEndpointDSTU23, verifyFhirVersion: true); p = client.Conformance(); } catch (NotSupportedException) { //Client uses 1.0.1, server states 1.0.0-7104 } client = new FhirClient(testEndpointDSTU23); p = client.Conformance(); //client = new FhirClient(testEndpointDSTU2); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); //client = new FhirClient(testEndpointDSTU22, verifyFhirVersion:true); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); client = new FhirClient(testEndpointDSTU12); try { p = client.Conformance(); Assert.Fail("Getting DSTU1 data using DSTU2 parsers should have failed"); } catch (FormatException) { // OK } }
public void TestConnectionError() { // todo: Thread error handling // In Forge, a Conformance request to a nonexisting endpoint, results in an exception that cannot be caught. // This unit tests simulates that behaviour, but here we can catch the error. // The error however is a NullReferenceException and not the original WebException. // Solution: The AsyncCallBack of GetResponseNoEx(this WebRequest req) should have a catch block. // -- MH. Exception register = null; try { string endpoint = "http://localhost:9876/fhir"; FhirClient client = new FhirClient(endpoint); client.Conformance(); } catch (Exception e) { register = e; } Assert.IsTrue(register != null); }