Exemple #1
0
        public void TestAdding()
        {
            var n       = new Node("node", new Dictionary <string, SDF>(), new List <SDF>());
            var matches = n.Find("/[has_child(subnode)]");

            Assert.AreEqual(0, matches.Count);

            n.AddChild("/", new Node("subnode", new Dictionary <string, SDF>(), new List <SDF>()));
            matches = n.Find("/[has_child(subnode)]");
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(n, matches[0].Value);

            matches = n.Find("/[has_attr(attr)]");
            Assert.AreEqual(0, matches.Count);

            n.AddAttribute("/", "attr", new BooleanLiteral(true));
            matches = n.Find("/[has_attr(attr)]");
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(n, matches[0].Value);

            matches = n.Find("[@attr=true]");
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(n, matches[0].Value);

            matches = n.Find("[@attr!=false]");
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(n, matches[0].Value);
        }