public void ParentConnections()
        {
            CreateParser("<custom>" + "<custom>something</custom>" + "</custom>");
            parser.AddScanner(new CustomScanner(this, false));
            parser.AddScanner(new AnotherScanner());
            ParseAndAssertNodeCount(3);

            CustomTag customTag = (CustomTag)node[0];

            AssertStringEquals("first custom tag html", "<CUSTOM></CUSTOM>", customTag.ToHtml());
            Assert.IsNull(customTag.Parent, "first custom tag should have no parent");

            customTag = (CustomTag)node[1];
            AssertStringEquals("first custom tag html", "<CUSTOM>something</CUSTOM>", customTag.ToHtml());
            Assert.IsNull(customTag.Parent, "second custom tag should have no parent");

            Node firstChild = customTag[0];

            AssertType("firstChild", typeof(StringNode), firstChild);
            CompositeTag parent = firstChild.Parent;

            Assert.IsNotNull(parent, "first child parent should not be null");
            Assert.AreSame(customTag, parent, "parent and custom tag should be the same");

            EndTag endTag = (EndTag)node[2];

            AssertStringEquals("first custom tag html", "</CUSTOM>", endTag.ToHtml());
            Assert.IsNull(endTag.Parent, "end tag should have no parent");
        }
Example #2
0
        private Tag CreateTag()
        {
            CompositeTag newTag =
                (CompositeTag)
                scanner.CreateTag(
                    new TagData(tag.ElementBegin, endTag.ElementEnd, startingLineNumber, endingLineNumber, tag.Text,
                                currLine, url, tag.EmptyXmlTag), new CompositeTagData(tag, endTag, nodeList));

            for (int i = 0; i < newTag.ChildCount; i++)
            {
                Node child = newTag[i];
                child.Parent = newTag;
            }
            return(newTag);
        }