public void HarvestScopedIdentifiers() { var bundleXml = File.ReadAllText("TestData\\validation\\bundle-contained-references.xml"); var bundle = (new FhirXmlParser()).Parse <Bundle>(bundleXml); Assert.IsNotNull(bundle); var cpNav = new PocoNavigator(bundle); var references = ReferenceHarvester.Harvest(cpNav); Assert.AreEqual(7, references.Count()); Assert.AreEqual("Bundle", cpNav.TypeName); // should not have navigated somewhere else // Get one of the entries with no contained resources, an Organization var orgNav = references.Single(r => r.Uri == "urn:uuid:04121321-4af5-424c-a0e1-ed3aab1c349d"); Assert.AreEqual("Organization", orgNav.Container.TypeName); var orgReferences = ReferenceHarvester.Harvest(orgNav.Container); Assert.AreEqual(0, orgReferences.Count()); Assert.AreEqual("Organization", orgNav.Container.TypeName); // should not have navigated somewhere else // Get one of the entries with contained resources, a Patient var patNav = references.First(r => r.Uri == "http://example.org/fhir/Patient/e"); Assert.AreEqual("Patient", patNav.Container.TypeName); var patReferences = ReferenceHarvester.Harvest(patNav.Container); Assert.AreEqual(2, patReferences.Count()); Assert.AreEqual("#orgX", patReferences.First().Uri); Assert.AreEqual("Bundle", cpNav.TypeName); // should not have navigated somewhere else }
private List <Scope> createScopeListForContainer() { var children = ReferenceHarvester.Harvest(Container).ToList(); foreach (var child in children) { child.Parent = this; child.UseCount = 1; } return(children); }