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 CompositeTagWithAnotherTagChild()
        {
            CreateParser("<Custom>" + "<Another/>" + "</Custom>");
            parser.AddScanner(new AnotherScanner());
            CustomTag customTag = ParseCustomTag(1);
            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(0, customTag.ElementBegin, "custom tag starting loc");
            Assert.AreEqual(26, customTag.ElementEnd, "custom tag ending loc");

            Node child = customTag[0];

            AssertType("child", typeof(AnotherTag), child);
            AnotherTag tag = (AnotherTag)child;

            Assert.AreEqual(8, tag.ElementBegin, "another tag start pos");
            Assert.AreEqual(17, tag.ElementEnd, "another tag ending pos");

            Assert.AreEqual(18, customTag.EndTag.ElementBegin, "custom end tag start pos");
            AssertStringEquals("child html", "<ANOTHER/>", child.ToHtml());
        }
        public void CompositeTagCorrectionWithSplitLines()
        {
            CreateParser("<custom>" + "<another><abcdefg>\n" + "</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 not 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(1, anotherTag.ChildCount, "anotherTag child count");
            Assert.AreEqual(9, anotherTag.ElementEnd, "anotherTag end loc");
            Assert.AreEqual(10, customTag.EndTag.ElementBegin, "custom end tag begin loc");
            Assert.AreEqual(8, customTag.EndTag.ElementEnd, "custom end tag end loc");
        }
        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 CompositeTagWithNestedTag()
        {
            CreateParser("<Custom>" + "<Another>" + "Hello" + "</Another>" + "<Custom/>" + "</Custom>" + "<Custom/>");
            parser.AddScanner(new CustomScanner(this));
            parser.AddScanner(new AnotherScanner());
            ParseAndAssertNodeCount(2);
            AssertType("first node", typeof(CustomTag), this.node[0]);
            AssertType("second node", typeof(CustomTag), this.node[1]);
            CustomTag customTag = (CustomTag)this.node[0];
            Node      node      = customTag[0];

            AssertType("first child", typeof(AnotherTag), node);
            AnotherTag anotherTag = (AnotherTag)node;

            Assert.AreEqual(1, anotherTag.ChildCount, "another tag children count");
            node = anotherTag[0];
            AssertType("nested child", typeof(StringNode), node);
            StringNode text = (StringNode)node;

            Assert.AreEqual("Hello", text.ToPlainTextString(), "text");
        }
        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());
        }