コード例 #1
0
ファイル: ElementQueryTests.cs プロジェクト: Condeti/spark
        public void TestVisitOnePathZeroMatch()
        {
            ElementQuery sut = new ElementQuery("Patient.name");

            Patient testPatient = new Patient();
            var result = new List<Object>() ;

            sut.Visit(testPatient, fd => result.Add(fd));

            Assert.AreEqual(testPatient.Name.Count, result.Where(ob => ob != null).Count());
        }
コード例 #2
0
ファイル: ElementQueryTests.cs プロジェクト: Condeti/spark
        public void TestVisitOnePathOneMatch()
        {
            ElementQuery sut = new ElementQuery("Patient.name");

            Patient testPatient = new Patient();
            var hn = new HumanName().WithGiven("Sjors").AndFamily("Jansen");
            testPatient.Name = new List<HumanName> { hn };

            var result = new List<Object>();

            sut.Visit(testPatient, fd => result.Add(fd));

            Assert.AreEqual(testPatient.Name.Count, result.Where(ob => ob != null).Count());
            Assert.IsTrue(result.Contains(hn));
        }
コード例 #3
0
ファイル: ElementQueryTests.cs プロジェクト: Condeti/spark
        public void TestVisitOnePathTwoMatches()
        {
            ElementQuery sut = new ElementQuery("Patient.name");

            Patient testPatient = new Patient();
            var hn1 = new HumanName().WithGiven("A").AndFamily("B");
            var hn2 = new HumanName().WithGiven("Y").AndFamily("Z");
            testPatient.Name = new List<HumanName> { hn1, hn2 };

            var result = new List<Object>();

            sut.Visit(testPatient, fd => result.Add(fd));

            Assert.AreEqual(testPatient.Name.Count, result.Where(ob => ob != null).Count());
            Assert.IsTrue(result.Contains(hn1));
            Assert.IsTrue(result.Contains(hn2));
        }
コード例 #4
0
        public static IEnumerable<Uri> GetReferences(this Resource resource, string include)
        {
            ElementQuery query = new ElementQuery(include);
            var list = new List<Uri>();

            query.Visit(resource, element =>
            {
                if (element is ResourceReference)
                {
                    Uri uri = (element as ResourceReference).Url;
                    if (uri != null) list.Add(uri);
                }
            });
            return list.Where(u => u != null);
        }