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 override void VisitEndTag(EndTag endTag)
 {
     if (IsPreTag(endTag))
     {
         preTagBeingProcessed = false;
     }
 }
        public void LinkDataContents()
        {
            CreateParser(
                "<a href=\"http://transfer.go.com/cgi/atransfer.pl?goto=http://www.signs.movies.com&name=114332&srvc=nws&context=283&guid=4AD5723D-C802-4310-A388-0B24E1A79689\" target=\"_new\"><img src=\"http://ad.abcnews.com/ad/sponsors/buena_vista_pictures/bvpi-ban0003.gif\" width=468 height=60 border=\"0\" alt=\"See Signs in Theaters 8-2 - Starring Mel Gibson\" align=><font face=\"verdana,arial,helvetica\" SIZE=\"1\"><b></b></font></a>",
                "http://transfer.go.com");
            // Register the image scanner
            LinkScanner linkScanner = new LinkScanner("-l");

            parser.AddScanner(linkScanner);
            parser.AddScanner(linkScanner.CreateImageScanner("-i"));

            ParseAndAssertNodeCount(1);
            Assert.IsTrue(node[0] is LinkTag, "Node 0 should be a link tag");
            LinkTag linkTag = (LinkTag)node[0];

            Assert.AreEqual(
                "http://transfer.go.com/cgi/atransfer.pl?goto=http://www.signs.movies.com&name=114332&srvc=nws&context=283&guid=4AD5723D-C802-4310-A388-0B24E1A79689",
                linkTag.Link, "Link URL");
            Assert.AreEqual("", linkTag.LinkText, "Link Text");
            Node[] containedNodes = new AbstractNode[10];
            int    i = 0;

            foreach (Node nestedNode in linkTag)
            {
                containedNodes[i++] = nestedNode;
            }
            Assert.AreEqual(5, i, "There should be 5 contained nodes in the link tag");
            Assert.IsTrue(containedNodes[0] is ImageTag, "First contained node should be an image tag");
            ImageTag imageTag = (ImageTag)containedNodes[0];

            Assert.AreEqual("http://ad.abcnews.com/ad/sponsors/buena_vista_pictures/bvpi-ban0003.gif", imageTag.ImageURL,
                            "Image Location");
            Assert.AreEqual("60", imageTag["HEIGHT"], "Image Height");
            Assert.AreEqual("468", imageTag["WIDTH"], "Image Width");
            Assert.AreEqual("0", imageTag["BORDER"], "Image Border");
            Assert.AreEqual("See Signs in Theaters 8-2 - Starring Mel Gibson", imageTag["ALT"], "Image Alt");
            Assert.IsTrue(containedNodes[1] is Tag, "Second contained node should be Tag");
            Tag tag1 = (Tag)containedNodes[1];

            Assert.AreEqual("font face=\"verdana,arial,helvetica\" SIZE=\"1\"", tag1.Text, "Tag Contents");
            Assert.IsTrue(containedNodes[2] is Tag, "Third contained node should be Tag");
            Tag tag2 = (Tag)containedNodes[2];

            Assert.AreEqual("b", tag2.Text, "Tag Contents");
            Assert.IsTrue(containedNodes[3] is EndTag, "Fourth contained node should be HTMLEndTag");
            EndTag endTag1 = (EndTag)containedNodes[3];

            Assert.AreEqual("b", endTag1.Text, "Fourth Tag contents");
            Assert.IsTrue(containedNodes[4] is EndTag, "Fifth contained node should be HTMLEndTag");
            EndTag endTag2 = (EndTag)containedNodes[4];

            Assert.AreEqual("font", endTag2.Text, "Fifth Tag contents");
        }
Exemplo n.º 4
0
 private void DoChildAndEndTagCheckOn(Node currentNode)
 {
     if (currentNode is EndTag)
     {
         EndTag possibleEndTag = (EndTag)currentNode;
         if (IsExpectedEndTag(possibleEndTag))
         {
             endTagFound = true;
             endTag      = possibleEndTag;
             return;
         }
     }
     nodeList.Add(currentNode);
     scanner.ChildNodeEncountered(currentNode);
 }
        public void FreshMeatBug()
        {
            CreateParser("<a>Revision</a>", "http://www.yahoo.com");
            // Register the image scanner
            parser.AddScanner(new LinkScanner("-l"));

            ParseAndAssertNodeCount(3);
            Assert.IsTrue(node[0] is Tag, "Node 0 should be a tag");
            Tag tag = (Tag)node[0];

            Assert.AreEqual("a", tag.Text, "Tag Contents");
            Assert.IsTrue(node[1] is StringNode, "Node 1 should be a string node");
            StringNode stringNode = (StringNode)node[1];

            Assert.AreEqual("Revision", stringNode.Text, "StringNode Contents");
            Assert.IsTrue(node[2] is EndTag, "Node 2 should be a string node");
            EndTag endTag = (EndTag)node[2];

            Assert.AreEqual("a", endTag.Text, "End Tag Contents");
        }
        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());
        }
Exemplo n.º 7
0
 private bool IsExpectedEndTag(EndTag possibleEndTag)
 {
     return(possibleEndTag.TagName.Equals(tag.TagName));
 }
Exemplo n.º 8
0
 public virtual void VisitEndTag(EndTag endTag)
 {
 }