public void TestSourceCaching() { var src = new CachedArtifactSource(ArtifactResolver.CreateDefault()); src.Prepare(); Stopwatch sw1 = new Stopwatch(); // Ensure looking up a failed endpoint repeatedly does not cost much time sw1.Start(); src.ReadResourceArtifact(new Uri("http://some.none.existant.address.nl")); sw1.Stop(); var sw2 = new Stopwatch(); sw2.Start(); src.ReadResourceArtifact(new Uri("http://some.none.existant.address.nl")); sw2.Stop(); Assert.IsTrue(sw2.ElapsedMilliseconds < sw1.ElapsedMilliseconds && sw2.ElapsedMilliseconds < 100); // Now try an existing artifact sw1.Restart(); src.ReadResourceArtifact(new Uri("http://hl7.org/fhir/v2/vs/0292")); sw1.Stop(); sw2.Restart(); src.ReadResourceArtifact(new Uri("http://hl7.org/fhir/v2/vs/0292")); sw2.Stop(); Assert.IsTrue(sw2.ElapsedMilliseconds < sw1.ElapsedMilliseconds && sw2.ElapsedMilliseconds < 100); }
public void LocateStructure() { var locator = new StructureLoader(ArtifactResolver.CreateDefault()); var profileUri = new Uri("http://hl7.org/fhir/Profile/Profile"); var prof = locator.LocateStructure(profileUri, new Code("Profile")); Assert.IsNotNull(prof); Assert.AreEqual("Profile", prof.Type); //Assert.AreEqual(profileUri.ToString(), prof.GetProfileLocation()); // Try to locate a structure that cannot be found in the given profile prof = locator.LocateStructure(profileUri, new Code("Patient")); Assert.IsNull(prof); profileUri = new Uri("http://take.from.disk/Profile/example-lipid-profile"); var profileUriWithFrag = new Uri(profileUri.ToString() + "#lipidResultMessage"); prof = locator.LocateStructure(profileUriWithFrag, new Code("MessageHeader")); Assert.IsNotNull(prof); Assert.AreEqual("MessageHeader", prof.Type); Assert.AreEqual("lipidResultMessage", prof.Name); //Assert.AreEqual(profileUri.ToString(), prof.GetProfileLocation()); // Try to locate a structure that cannot be found in the profile by name profileUriWithFrag = new Uri(profileUri.ToString() + "#XXX"); prof = locator.LocateStructure(profileUriWithFrag, new Code("Profile")); Assert.IsNull(prof); }
public void TestExpandChild() { var loader = new StructureLoader(ArtifactResolver.CreateDefault()); var profStruct = loader.LocateStructure(new Uri("http://hl7.org/fhir/Profile/Profile"), new Code("Profile")); var nav = new ElementNavigator(profStruct.Snapshot); nav.JumpToFirst("Profile.telecom"); Assert.IsTrue(nav.ExpandElement(loader)); Assert.IsTrue(nav.MoveToChild("period")); nav.JumpToFirst("Profile.structure.differential"); Assert.IsTrue(nav.ExpandElement(loader)); Assert.IsTrue(nav.MoveToChild("element")); }
public void TestExpandChild() { var loader = new StructureLoader(ArtifactResolver.CreateDefault()); var profStruct = loader.Locate(new Uri("http://hl7.org/fhir/Profile/Profile"), new Code("Profile")); var nav = new ElementNavigator(profStruct); nav.JumpToFirst("Profile.telecom"); Assert.IsTrue(nav.ExpandElement(loader)); Assert.IsTrue(nav.MoveToChild("period")); nav.JumpToFirst("Profile.extensionDefn.definition"); Assert.IsTrue(nav.ExpandElement(loader)); Assert.IsTrue(nav.MoveToChild("max")); }
public void RetrieveArtifactMulti() { var resolver = ArtifactResolver.CreateDefault(); resolver.Prepare(); var vs = resolver.ReadResourceArtifact(new Uri("http://hl7.org/fhir/v2/vs/0292")); Assert.IsNotNull(vs); Assert.IsTrue(vs is ValueSet); using (var a = resolver.ReadContentArtifact("patient.sch")) { Assert.IsNotNull(a); } var artifact = resolver.ReadResourceArtifact(new Uri("http://fhir.healthintersections.com.au/open/Profile/alert")); Assert.IsNotNull(artifact); Assert.IsTrue(artifact is Profile); Assert.AreEqual("alert", ((Profile)artifact).Name); }
public ProfileExpander() { _loader = new StructureLoader(new CachedArtifactSource(ArtifactResolver.CreateDefault())); }
public void Setup() { _source = new CachedArtifactSource(ArtifactResolver.CreateDefault()); }