Пример #1
0
        public void WebComponentListsAllDescendents()
        {
            var x   = new Xcom();
            var div = Element.Create("div");

            div.Id = "lala";
            x.AppendChild(div);
            var set = new HashSet <string>();

            foreach (var node in GetAllDescendents(x))
            {
                if (node is Element child && !string.IsNullOrEmpty(child.Id))
                {
                    set.Add(child.Id);
                }
            }
            Assert.Contains("div1", set);
            Assert.Contains("div2", set);
            Assert.Contains("div1a", set);
            Assert.Contains("lala", set);
        }
Пример #2
0
        public void FlattenedChildrenIncludesPrintedOnes()
        {
            var container = Element.Create("div");
            var x         = new Xcom();
            var div       = Element.Create("div");

            div.Id = "lala";
            x.AppendChild(div);
            container.AppendChild(x);
            var set = new HashSet <string>();

            foreach (var node in GetFlattened(container))
            {
                if (node is Element child && !string.IsNullOrEmpty(child.Id))
                {
                    set.Add(child.Id);
                }
            }
            Assert.Contains("div1", set);
            Assert.Contains("div2", set);
            Assert.Contains("div1a", set);
            Assert.DoesNotContain("lala", set);
        }