示例#1
0
        public void BasicParseIsSuccessful()
        {
            TagParser TP = new TagParser {
                Content = HTML_CONTENT1
            };

            TP.ParseContent();
            Assert.AreEqual(14, TP.TagCount, "Tag count not 13");
            Assert.AreEqual(3, TP.FindTag("BODY"), "BODY tag not found at index 3");
            Assert.AreEqual(-1, TP.FindTag("XYZ"), "xyz (missing) tag not -1");
            Assert.AreEqual(6, TP.FindTag("p", 0, 2), "second P tag does not have index of 6");
            Assert.AreEqual(2, TP.SpecificTagCount("P"), "count of P tags is not 2");
            var inputNdx = TP.FindTag("INPUT");

            Assert.IsTrue(inputNdx >= 0, "input tag was not found");
            var rawElements = TP.GetTagAttributeTextRaw(inputNdx);

            Assert.AreEqual("name='test' id='myid'", rawElements, "raw element extract for input tag is incorrect.");
            Assert.AreEqual("HTML", TP.Tag(0), "First tag not HTML");
            Assert.AreEqual("HEAD", TP.Tag(1), "Second tag not HEAD");
            Assert.AreEqual("Heading", TP.TagPostText(1), "Text after second tag not Heading");
        }