public void GetAbsoluteUri()
        {
            var r = new ResourceReference {
                Reference = "Patient/4"
            };

            Assert.AreEqual("http://someserver.org/fhir/Patient/4", r.GetAbsoluteUriForReference("http://someserver.org/fhir/Observation/5").ToString());

            r.Reference = "http://otherserver.org/fhir/Patient/4";
            Assert.AreEqual("http://otherserver.org/fhir/Patient/4", r.GetAbsoluteUriForReference("http://someserver.org/fhir/Observation/5").ToString());
            Assert.AreEqual("http://otherserver.org/fhir/Patient/4", r.GetAbsoluteUriForReference("urn:uuid:d0dd51d3-3ab2-4c84-b697-a630c3e40e7a").ToString());

            r.Reference = "urn:uuid:d0dd51d3-3ab2-4c84-b697-a630c3e40e7a";
            Assert.AreEqual("urn:uuid:d0dd51d3-3ab2-4c84-b697-a630c3e40e7a", r.GetAbsoluteUriForReference("http://someserver.org/fhir/Observation/5").ToString());

            try
            {
                r.Reference = "Patient/4";
                var dummy = r.GetAbsoluteUriForReference("urn:uuid:d0dd51d3-3ab2-4c84-b697-a630c3e40e7a");
                Assert.Fail();
            }
            catch
            { }
        }
Beispiel #2
0
 /// <summary>
 /// When a ResourceReference is relative, use the parent resource's fullUrl (e.g. from a Bundle's entry)
 /// to make it absolute.
 /// </summary>
 /// <param name="reference">The ResourceReference to get the (possibily relative) url from</param>
 /// <param name="parentResourceUri">Absolute uri representing the location of the resource this reference is in.</param>
 /// <remarks>Implements (part of the logic) as described in bundle.html#6.7.4.1</remarks>
 /// <returns></returns>
 public static Uri GetAbsoluteUriForReference(this ResourceReference reference, string parentResourceUri)
 {
     return(reference.GetAbsoluteUriForReference(new Uri(parentResourceUri, UriKind.RelativeOrAbsolute)));
 }