Beispiel #1
0
        public void TestDynaBinding()
        {
            var input = (ElementNode.Node("root",
                                          ElementNode.Valued("child", "Hello world!", "string"), ElementNode.Valued("child", 4L, "integer"))).ToNavigator();

            Assert.Equal("ello", input.Scalar(@"$this.child[0].substring(1,%context.child[1])"));
        }
        public void PrimitiveChildMatching()
        {
            var boolean    = _source.FindStructureDefinitionForCoreType(FHIRDefinedType.Boolean);
            var boolDefNav = ElementDefinitionNavigator.ForSnapshot(boolean);

            boolDefNav.MoveToFirstChild();

            var data = ElementNode.Valued("active", true, FHIRDefinedType.Boolean.GetLiteral(),
                                          ElementNode.Node("extension",
                                                           ElementNode.Valued("value", 4, "integer")),
                                          ElementNode.Node("nonExistant")
                                          ).ToNavigator();

            var matches = ChildNameMatcher.Match(boolDefNav, data);

            Assert.AreEqual(1, matches.UnmatchedInstanceElements.Count);
            Assert.AreEqual(3, matches.Matches.Count());                     // id, extension, value
            Assert.AreEqual(0, matches.Matches[0].InstanceElements.Count()); // id
            Assert.AreEqual(1, matches.Matches[1].InstanceElements.Count()); // extension
            Assert.AreEqual(1, matches.Matches[2].InstanceElements.Count()); // value

            Assert.AreEqual("extension", matches.Matches[1].InstanceElements.First().Name);
            Assert.AreEqual("extension", matches.Matches[1].Definition.PathName);
            Assert.AreEqual("active", matches.Matches[2].InstanceElements.First().Name);
            Assert.AreEqual("value", matches.Matches[2].Definition.PathName);
        }
        public void TestEmptyElement()
        {
            var boolSd = _source.FindStructureDefinitionForCoreType(FHIRDefinedType.Boolean);
            var data   = ElementNode.Node("active").ToNavigator();

            var result = _validator.Validate(data, boolSd);

            Assert.IsFalse(result.Success);
            Assert.IsTrue(result.ToString().Contains("must not be empty"));
        }
Beispiel #4
0
 public ElementNodeTests()
 {
     patient = ElementNode.Node("Patient", "Patient",
                                ElementNode.Valued("active", true, FHIRDefinedType.Boolean.GetLiteral(),
                                                   ElementNode.Valued("id", "myId1"),
                                                   ElementNode.Valued("id", "myId2"),
                                                   ElementNode.Node("extension",
                                                                    ElementNode.Valued("value", 4, "integer")),
                                                   ElementNode.Node("extension",
                                                                    ElementNode.Valued("value", "world!", "string"))));
 }
Beispiel #5
0
        public static IElementNavigator QuerySelect(this IElementNavigator nav, Query query)
        {
            var root = ElementNode.Node(query.From);

            foreach (var field in query.Fields)
            {
                var subtree = nav.Select(field.Expression);
                root.Apply(subtree, field.Name);
            }
            return(root.ToNavigator());
        }
        public void ValidateCardinality()
        {
            var boolSd = _source.FindStructureDefinitionForCoreType(FHIRDefinedType.Boolean);
            var data   = ElementNode.Valued("active", true, FHIRDefinedType.Boolean.GetLiteral(),
                                            ElementNode.Valued("id", "myId1"),
                                            ElementNode.Valued("id", "myId2"),
                                            ElementNode.Node("extension",
                                                             ElementNode.Valued("value", 4, "integer")),
                                            ElementNode.Node("extension",
                                                             ElementNode.Valued("value", "world!", "string"))).ToNavigator();

            var report = _validator.Validate(data, boolSd);

            Assert.AreEqual(3, report.ListErrors().Count());
        }
Beispiel #7
0
        public ElementNodeTests()
        {
            var annotatedNode = ElementNode.Valued("id", "myId1");

            (annotatedNode as IAnnotatable).AddAnnotation("a string annotation");

            patient = ElementNode.Node("Patient", "Patient",
                                       ElementNode.Valued("active", true, "boolean",
                                                          annotatedNode,
                                                          ElementNode.Valued("id", "myId2"),
                                                          ElementNode.Node("extension",
                                                                           ElementNode.Valued("value", 4, "integer")),
                                                          ElementNode.Node("extension",
                                                                           ElementNode.Valued("value", "world!", "string"))));
        }