public void CanSerializeThroughNavigatorAndCompare() { var tpXml = File.ReadAllText(@"TestData\fp-test-patient.xml"); var nav = getXmlElement(tpXml); var output = nav.ToXml(); XmlAssert.AreSame("fp-test-patient.xml", tpXml, output, ignoreSchemaLocation: true); }
public void CheckCopyAllFields() { string xml = ReadTestData("TestPatient.xml"); var p = new FhirXmlParser().Parse <Patient>(xml); var p2 = (Patient)p.DeepCopy(); var xml2 = new FhirXmlSerializer().SerializeToString(p2); XmlAssert.AreSame("TestPatient.xml", xml, xml2); }
public void CheckCopyCarePlan() { string xml = ReadTestData(@"careplan-example-f201-renal.xml"); var p = new FhirXmlParser().Parse <CarePlan>(xml); var p2 = (CarePlan)p.DeepCopy(); var xml2 = new FhirXmlSerializer().SerializeToString(p2); XmlAssert.AreSame("careplan-example-f201-renal.xml", xml, xml2); }
public void CheckCopyAllFields() { string xml = File.ReadAllText(@"TestData\TestPatient.xml"); var p = new FhirXmlParser().Parse <Patient>(xml); var p2 = (Patient)p.DeepCopy(); var xml2 = FhirSerializer.SerializeResourceToXml(p2); XmlAssert.AreSame(xml, xml2); }
public void CheckCopyCarePlan() { string xml = File.ReadAllText(@"TestData\careplan-example-f201-renal.xml"); var p = new FhirXmlParser().Parse <CarePlan>(xml); var p2 = (CarePlan)p.DeepCopy(); var xml2 = FhirSerializer.SerializeResourceToXml(p2); XmlAssert.AreSame(xml, xml2); }
private void compareFile(string expectedFile, string actualFile) { if (expectedFile.EndsWith(".xml")) { XmlAssert.AreSame(File.ReadAllText(expectedFile), File.ReadAllText(actualFile)); } else { JsonAssert.AreSame(File.ReadAllText(expectedFile), File.ReadAllText(actualFile)); } }
private void compareFile(string expectedFile, string actualFile, List <string> errors) { if (expectedFile.EndsWith(".xml")) { XmlAssert.AreSame(new FileInfo(expectedFile).Name, File.ReadAllText(expectedFile), File.ReadAllText(actualFile)); } else { JsonAssert.AreSame(new FileInfo(expectedFile).Name, File.ReadAllText(expectedFile), File.ReadAllText(actualFile), errors); } }
public void PingpongXml() { var tp = File.ReadAllText(Path.Combine("TestData", "fp-test-patient.xml")); // will allow whitespace and comments to come through var navXml = XmlParsingHelpers.ParseToTypedElement(tp, new PocoStructureDefinitionSummaryProvider()); var json = navXml.ToJson(); var navJson = JsonParsingHelpers.ParseToTypedElement(json, new PocoStructureDefinitionSummaryProvider()); var xml = navJson.ToXml(); XmlAssert.AreSame("fp-test-patient.xml", tp, xml, ignoreSchemaLocation: true); }
public void CanSerializeFromPoco() { var tpXml = File.ReadAllText(@"TestData\fp-test-patient.xml"); var pser = new FhirXmlParser(new ParserSettings { DisallowXsiAttributesOnRoot = false }); var pat = pser.Parse <Patient>(tpXml); var nav = pat.ToTypedElement(); var output = nav.ToXml(); XmlAssert.AreSame("fp-test-patient.xml", tpXml, output, ignoreSchemaLocation: true); }
private static void compareFile(string expectedFile, string actualFile) { if (expectedFile.EndsWith(".xml")) { XmlAssert.AreSame(new FileInfo(expectedFile).Name, File.ReadAllText(expectedFile), File.ReadAllText(actualFile)); } else { if (new FileInfo(expectedFile).Name != "json-edge-cases.json") { JsonAssert.AreSame(File.ReadAllText(expectedFile), File.ReadAllText(actualFile)); } } }
public void RoundTripOneExample() { string exampleXml = @"TestData\testscript-example(example).xml"; var original = File.ReadAllText(exampleXml); var t = new FhirXmlParser().Parse <TestScript>(original); var outputXml = FhirSerializer.SerializeResourceToXml(t); XmlAssert.AreSame(original, outputXml); var outputJson = FhirSerializer.SerializeResourceToJson(t); var t2 = new FhirJsonParser().Parse <TestScript>(outputJson); // Assert.IsTrue(t.IsExactly(t2)); var outputXml2 = FhirSerializer.SerializeResourceToXml(t2); XmlAssert.AreSame(original, outputXml2); }
public void RoundTripOneExample() { string testFileName = "testscript-example(example).xml"; var original = TestDataHelper.ReadTestData(testFileName); var t = new FhirXmlParser().Parse <TestScript>(original); var outputXml = FhirSerializer.SerializeResourceToXml(t); XmlAssert.AreSame(testFileName, original, outputXml); var outputJson = FhirSerializer.SerializeResourceToJson(t); var t2 = new FhirJsonParser().Parse <TestScript>(outputJson); Assert.IsTrue(t.IsExactly(t2)); var outputXml2 = FhirSerializer.SerializeResourceToXml(t2); XmlAssert.AreSame(testFileName, original, outputXml2); }
private void roundTripOneExample(string filename) { string testFileName = filename; var original = TestDataHelper.ReadTestData(testFileName); var t = new FhirXmlParser().Parse <Resource>(original); var outputXml = new FhirXmlSerializer().SerializeToString(t); XmlAssert.AreSame(testFileName, original, outputXml); var outputJson = new FhirJsonSerializer().SerializeToString(t); var t2 = new FhirJsonParser().Parse <Resource>(outputJson); Assert.IsTrue(t.IsExactly(t2)); var outputXml2 = new FhirXmlSerializer().SerializeToString(t2); XmlAssert.AreSame(testFileName, original, outputXml2); }
public static void RoundtripXml(Func <string, object> navCreator) { var tp = File.ReadAllText(@"TestData\fp-test-patient.xml"); // will allow whitespace and comments to come through var nav = navCreator(tp); var outputBuilder = new StringBuilder(); IElementDefinitionSummary serInfo = null; switch (nav) { case ISourceNode isn: serInfo = null; break; case ITypedElement ien: serInfo = ien.Definition; break; default: throw Error.InvalidOperation("Fix unit test"); } string output = null; if (nav is ISourceNode isn2) { output = isn2.ToXml(); } else if (nav is ITypedElement ien2) { output = ien2.ToXml(); } else { throw Error.InvalidOperation("Fix unit test"); } XmlAssert.AreSame("fp-test-patient.xml", tp, output); }
public void EdgeCaseRoundtrip() { Stream xmlExample = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Hl7.Fhir.Test.TestPatient.xml"); string xml = new StreamReader(xmlExample).ReadToEnd(); Stream jsonExample = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Hl7.Fhir.Test.TestPatient.json"); string json = new StreamReader(jsonExample).ReadToEnd(); var poco = FhirParser.ParseResourceFromXml(xml); Assert.IsNotNull(poco); var output = FhirSerializer.SerializeResourceToXml(poco); Assert.IsNotNull(output); XmlAssert.AreSame(xml, output); poco = FhirParser.ParseResourceFromJson(json); Assert.IsNotNull(poco); output = FhirSerializer.SerializeResourceToJson(poco); Assert.IsNotNull(output); JsonAssert.AreSame(json, output); }
public void SuccessfullyCreated() { var patient = createPatient(); var pat = new Patient(); var containedObs = new Observation { Value = new FhirBoolean(true) }; pat.Contained.Add(containedObs); pat.ActiveElement = new FhirBoolean(true) { ElementId = "myId1" }; pat.ActiveElement.AddAnnotation("a string annotation"); pat.ActiveElement.SetIntegerExtension("urn:1", 4); pat.ActiveElement.SetStringExtension("urn:2", "world!"); pat.Identifier.Add(new Identifier("http://nu.nl", "1234567")); pat.Identifier.Add(new Identifier("http://toen.nl", "7654321")); XmlAssert.AreSame("in place", pat.ToXml(), patient.ToXml()); }
public void ExpandProfile() { var expander = new ProfileExpander(_source); // This file will be found local to the test DLL, based on its it, not its url //var diff = (Profile)FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\ProfileProcedureNO.xml")); var diff = (Profile)FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\example-lipid-profile-differential.xml")); Assert.IsNotNull(diff); expander.Expand(diff); var snapshot = expander.Expand(diff); Assert.IsNotNull(diff); var xmlA = FhirSerializer.SerializeResourceToXml(diff); File.WriteAllText("c:\\temp\\expanded.xml", xmlA); var xmlE = File.ReadAllText(@"TestData\example-lipid-profile.xml"); XmlAssert.AreSame(xmlE, xmlA); }