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");
        }
        public void CompositeTagWithDeadlock()
        {
            CreateParser("<custom>" + "<another>something" + "</custom>" + "<custom>" + "<another>else</another>" +
                         "</custom>");
            parser.AddScanner(new AnotherScanner(true));
            CustomTag customTag = ParseCustomTag(2);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(1, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            AnotherTag anotherTag = (AnotherTag)customTag[0];

            Assert.AreEqual(1, anotherTag.ChildCount, "anotherTag child count");
            StringNode stringNode = (StringNode)anotherTag[0];

            AssertStringEquals("anotherTag child text", "something", stringNode.ToPlainTextString());
            AssertStringEquals("first custom tag html", "<CUSTOM><ANOTHER>something</ANOTHER></CUSTOM>",
                               customTag.ToHtml());
            customTag = (CustomTag)node[1];
            AssertStringEquals("second custom tag html", "<CUSTOM><ANOTHER>else</ANOTHER></CUSTOM>", customTag.ToHtml());
        }
        public void TwoConsecutiveErroneousCompositeTags()
        {
            CreateParser("<custom>something" + "<custom></endtag>");
            parser.AddScanner(new CustomScanner(this, false));
            ParseAndAssertNodeCount(2);
            CustomTag customTag = (CustomTag)node[0];
            int       x         = customTag.ChildCount;

            Assert.AreEqual(1, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(25, customTag.ElementEnd, "ending loc of custom tag");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            AssertStringEquals("first custom tag", "<CUSTOM>something</CUSTOM>", customTag.ToHtml());
            customTag = (CustomTag)node[1];
            AssertStringEquals("second custom tag", "<CUSTOM></ENDTAG></CUSTOM>", customTag.ToHtml());
        }
        public void EmptyCompositeTag()
        {
            CreateParser("<Custom/>");
            CustomTag customTag = ParseCustomTag(1);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(0, customTag.ChildCount, "child count");
            Assert.IsTrue(customTag.EmptyXmlTag, "custom tag should be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(8, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            AssertStringEquals("html", "<CUSTOM/>", customTag.ToHtml());
        }
        public void ErroneousCompositeTagWithChildren()
        {
            CreateParser("<custom>" + "<firstChild>" + "<secondChild>");
            CustomTag customTag = ParseCustomTag(1);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(2, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            AssertStringEquals("html", "<CUSTOM><FIRSTCHILD><SECONDCHILD></CUSTOM>", customTag.ToHtml());
        }
        public void EmptyCompositeTagAnotherStyle()
        {
            CreateParser("<Custom></Custom>");
            CustomTag customTag = ParseCustomTag(1);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(0, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            Assert.AreEqual("<CUSTOM></CUSTOM>", customTag.ToHtml(), "html");
        }
        public void CompositeTagWithErroneousAnotherTag()
        {
            CreateParser("<custom>" + "<another>" + "</custom>");
            parser.AddScanner(new AnotherScanner(true));
            CustomTag customTag = ParseCustomTag(1);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(1, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            AnotherTag anotherTag = (AnotherTag)customTag[0];

            Assert.AreEqual(26, anotherTag.ElementEnd, "another tag ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            AssertStringEquals("html", "<CUSTOM><ANOTHER></ANOTHER></CUSTOM>", customTag.ToHtml());
        }
        public void CompositeTagWithSelfChildren()
        {
            CreateParser("<custom>" + "<custom>something</custom>" + "</custom>");
            parser.AddScanner(new CustomScanner(this, false));
            parser.AddScanner(new AnotherScanner());
            ParseAndAssertNodeCount(3);

            CustomTag customTag = (CustomTag)node[0];
            int       x         = customTag.ChildCount;

            Assert.AreEqual(0, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");

            AssertStringEquals("first custom tag html", "<CUSTOM></CUSTOM>", customTag.ToHtml());
            customTag = (CustomTag)node[1];
            AssertStringEquals("first custom tag html", "<CUSTOM>something</CUSTOM>", customTag.ToHtml());
            EndTag endTag = (EndTag)node[2];

            AssertStringEquals("first custom tag html", "</CUSTOM>", endTag.ToHtml());
        }
        public void CompositeTagWithErroneousAnotherTagAndLineBreak()
        {
            CreateParser("<another>" + "<custom>\n" + "</custom>");
            parser.AddScanner(new AnotherScanner());
            parser.AddScanner(new CustomScanner(this));
            ParseAndAssertNodeCount(2);
            AnotherTag anotherTag = (AnotherTag)node[0];

            Assert.AreEqual(0, anotherTag.ChildCount, "another tag child count");

            CustomTag customTag = (CustomTag)node[1];
            int       x         = customTag.ChildCount;

            Assert.AreEqual(0, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");
            Assert.AreEqual(9, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(16, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(2, customTag.tagData.EndLine, "ending line position");
            AssertStringEquals("another tag html", "<ANOTHER></ANOTHER>", anotherTag.ToHtml());
            AssertStringEquals("custom tag html", "<CUSTOM>\r\n</CUSTOM>", customTag.ToHtml());
        }