Example #1
0
        public void ParseMeta()
        {
            var poco = (Meta)FhirParser.ParseFromXml(metaXml, typeof(Meta));
            var xml  = FhirSerializer.SerializeToXml(poco, root: "meta");

            Assert.IsTrue(poco.IsExactly(metaPoco));
            Assert.AreEqual(metaXml, xml);
        }
Example #2
0
        public override object InternalExecute(Program program, object argument1)
        {
                        #if NILPROPOGATION
            if (argument1 == null)
            {
                return(null);
            }
                        #endif

            return(FhirSerializer.SerializeToXml((Base)argument1));
        }
Example #3
0
        private void test(Model.Resource resource, String expression, IEnumerable <XElement> expected)
        {
            var tpXml = FhirSerializer.SerializeToXml(resource);
            var npoco = new PocoNavigator(resource);
            //       FhirPathEvaluatorTest.Render(npoco);

            IEnumerable <IElementNavigator> actual = npoco.Select(expression);

            Assert.Equal(expected.Count(), actual.Count());

            expected.Zip(actual, compare).Count();
        }
Example #4
0
        public void BundleLinksUnaltered()
        {
            var b = new Bundle();

            b.NextLink = new Uri("Organization/123456/_history/123456", UriKind.Relative);

            var xml = FhirSerializer.SerializeToXml(b);

            b = (Bundle)FhirParser.ParseFromXml(xml);

            Assert.IsTrue(!b.NextLink.ToString().EndsWith("/"));
        }
Example #5
0
        public void TestUseFhirParserToTagList()
        {
            TagList l = new TagList();

            l.Category = new List <Tag>();

            l.Category.Add(new Tag("http://www.nu.nl/tags", Tag.FHIRTAGSCHEME_GENERAL, "No!"));
            l.Category.Add(new Tag("http://www.furore.com/tags", Tag.FHIRTAGSCHEME_GENERAL, "Maybe, indeed"));

            var xml = FhirSerializer.SerializeToXml(l);

            Assert.AreEqual(xmlTagList, xml);
        }
        public void TestCanonicalUrlConflicts()
        {
            //const string srcFileName = "extension-definitions.xml";
            const string dupFileName = "diagnosticorder-reason-duplicate";
            const string url         = "http://hl7.org/fhir/StructureDefinition/diagnosticorder-reason";

            var za = ZipSource.CreateValidationSource();

            // Try to find a core extension
            var ext = za.ResolveByCanonicalUri(url);

            Assert.IsNotNull(ext);
            Assert.IsTrue(ext is StructureDefinition);

            // Save back to disk to create a conflicting duplicate
            var b = new Bundle();

            b.AddResourceEntry(ext, url);
            var xml       = FhirSerializer.SerializeToXml(b);
            var filePath  = Path.Combine(DirectorySource.SpecificationDirectory, dupFileName) + ".xml";
            var filePath2 = Path.Combine(DirectorySource.SpecificationDirectory, dupFileName) + "2.xml";

            File.WriteAllText(filePath, xml);
            File.WriteAllText(filePath2, xml);

            bool conflictException = false;

            try
            {
                var fa  = new DirectorySource();
                var res = fa.ResolveByCanonicalUri(url);
            }
            catch (CanonicalUrlConflictException ex)
            {
                Debug.WriteLine("{0}:\r\n{1}", ex.GetType().Name, ex.Message);
                Assert.IsNotNull(ex.Conflicts);
                Assert.AreEqual(1, ex.Conflicts.Length);
                var conflict = ex.Conflicts[0];
                Assert.AreEqual(url, conflict.Url);
                Assert.IsTrue(conflict.FilePaths.Contains(filePath));
                Assert.IsTrue(conflict.FilePaths.Contains(filePath2));
                conflictException = true;
            }
            finally
            {
                try { File.Delete(filePath); } catch { }
                File.Delete(filePath2);
            }
            Assert.IsTrue(conflictException);
        }
Example #7
0
        public void SerializeMeta()
        {
            var xml = FhirSerializer.SerializeToXml(metaPoco, root: "meta");

            Assert.AreEqual(metaXml, xml);
        }