Esempio n. 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");
        }
Esempio n. 2
0
        public void ParseAttributesWithoutSpacesIsSuccessful()
        {
            TagParser TP = new TagParser {
                Content = HTML_CONTENT_SPACES
            };

            TP.ParseContent();
            Assert.AreEqual(1, TP.TagCount, "Tag count not 0");
            Assert.AreEqual("P", TP.Tag(0), "Tag 0 not P");
            var kvps = TP.ParseTagAttributes(0).ToArray();

            Assert.AreEqual("CLASS", kvps[0].Key, "Key 0 incorrect");
            Assert.AreEqual("dummy1 dummy2", kvps[0].Value, "Value 0 incorrect");
            Assert.AreEqual("ID", kvps[1].Key, "Key 1 incorrect");
            Assert.AreEqual("test", kvps[1].Value, "Value 1 incorrect");
        }
Esempio n. 3
0
        public void ParseAttributesWithWhitespaceRightAfterElementIsSuccessful()
        {
            TagParser TP = new TagParser(true, true, '<', '>')
            {
                Content = XML_CONTENT2
            };

            TP.ParseContent();
            var svgNdx = TP.FindTag("svg");

            Assert.AreEqual(1, svgNdx, "svg tag index != 1");
            var kvps = TP.ParseTagAttributes(svgNdx).ToArray();

            Assert.AreEqual(3, kvps.Length, "array not 3 elements");
            Assert.AreEqual("id", kvps[0].Key, "id not first attribute");
            Assert.AreEqual("svg99", kvps[0].Value, "id value incorrect");
            var tagName = TP.Tag(svgNdx);

            Assert.AreEqual("svg", tagName, "tag not svg");
            Assert.AreEqual(3, tagName.Length, "svg tag not 3 long");
        }