public void GenerateNorwegianSnapshots() { var mySource = new FileDirectoryArtifactSource(@"C:\Git\helsenord.ig\Source\Chapter.3.Package", includeSubdirectories: false); var stdSource = ZipArtifactSource.CreateValidationSource(); var resolver = new ArtifactResolver(new MultiArtifactSource(mySource, stdSource)); var sources = new[] { "noHealthcareService", "noHealthcareServiceLocation", "noOrganization", "noPractitioner", "acronym" }; var generator = new SnapshotGenerator(resolver, markChanges: false); foreach (var source in sources) { var sd = resolver.GetStructureDefinition("http://hl7.no/fhir/StructureDefinition/" + source); Assert.IsNotNull(sd, "Cannot find SD " + sd.Url); generator.Generate(sd); File.WriteAllText(@"C:\Git\helsenord.ig\Source\Chapter.3.Package\structure." + source + ".xml", FhirSerializer.SerializeResourceToXml(sd)); } }
private static void generateSnapshotAndCompare(StructureDefinition original, ArtifactResolver source) { var generator = new SnapshotGenerator(source, markChanges: false); var expanded = (StructureDefinition)original.DeepCopy(); Assert.IsTrue(original.IsExactly(expanded)); generator.Generate(expanded); // Simulate bug in Grahame's expander if (original.Snapshot.Element.Count == expanded.Snapshot.Element.Count) { for (var ix = 0; ix < expanded.Snapshot.Element.Count; ix++) { if (original.Snapshot.Element[ix].Path == expanded.Snapshot.Element[ix].Path) { expanded.Snapshot.Element[ix].Min = original.Snapshot.Element[ix].Min; expanded.Snapshot.Element[ix].MustSupport = original.Snapshot.Element[ix].MustSupport; } } } var areEqual = original.IsExactly(expanded); if (!areEqual) { File.WriteAllText("c:\\temp\\snapshotgen-source.xml", FhirSerializer.SerializeResourceToXml(original)); File.WriteAllText("c:\\temp\\snapshotgen-dest.xml", FhirSerializer.SerializeResourceToXml(expanded)); } Assert.IsTrue(areEqual); }