public void ParseParameterSpace() { Tag tag; EndTag etag; StringNode snode; Node node = null; string lin1 = "<A yourParameter = \"Kaarle\">Kaarle's homepage</A>"; CreateParser(lin1); NodeIterator en = parser.GetEnumerator(); System.Collections.Hashtable h; string a, nice; try { Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; tag = (Tag)node; h = tag.Attributes; a = (string)h[Tag.TAGNAME]; nice = (string)h["YOURPARAMETER"]; Assert.AreEqual(a, "A", "Link tag (A)"); Assert.AreEqual("Kaarle", nice, "yourParameter value"); if (!(node is LinkTag)) { // linkscanner has eaten up this piece Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; snode = (StringNode)node; Assert.AreEqual(snode.Text, "Kaarle's homepage", "Value of element"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; etag = (EndTag)node; Assert.AreEqual(etag.Text, "A", "Still patragraph endtag"); } // testing rest } catch (System.InvalidCastException) { Assert.Fail("Bad class element = " + node.GetType().FullName); } }
public void ParseParameterG() { Tag tag; EndTag etag; StringNode snode; Node node = null; string lin1 = "<G href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaila\">Kaarle's homepage</G><p>Paragraph</p>"; CreateParser(lin1); NodeIterator en = parser.GetEnumerator(); System.Collections.Hashtable h; string a, href, myValue, nice; try { Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; tag = (Tag)node; h = tag.Attributes; a = (string)h[Tag.TAGNAME]; href = (string)h["HREF"]; myValue = (string)h["MYPARAMETER"]; nice = (string)h["YOURPARAMETER"]; Assert.AreEqual(a, "G", "The tagname should be G"); Assert.AreEqual(href, "http://www.iki.fi/kaila", "Check the http address"); Assert.AreEqual(myValue, "", "myValue is empty"); Assert.AreEqual(nice, "Kaila", "The second parameter value"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; snode = (StringNode)node; Assert.AreEqual(snode.Text, "Kaarle's homepage", snode.Text, "Kaarle's homepage"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; etag = (EndTag)node; Assert.AreEqual(etag.Text, "G", "Endtag is G"); // testing rest Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; tag = (Tag)node; Assert.AreEqual(tag.Text, "p", "Follow up by p-tag"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; snode = (StringNode)node; Assert.AreEqual(snode.Text, "Paragraph", "Verify the paragraph text"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; etag = (EndTag)node; Assert.AreEqual(etag.Text, "p", "Still patragraph endtag"); } catch (System.InvalidCastException) { Assert.Fail("Bad class element = " + node.GetType().FullName); } }
public void ParseParameterA() { Tag tag; EndTag etag; StringNode snode; Node node = null; string lin1 = "<A href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaarle Kaaila\">Kaarle's homepage</A><p>Paragraph</p>"; CreateParser(lin1); NodeIterator en = parser.GetEnumerator(); System.Collections.Hashtable h; string a, href, myValue, nice; try { Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; tag = (Tag)node; h = tag.Attributes; a = (string)h[Tag.TAGNAME]; href = (string)h["HREF"]; myValue = (string)h["MYPARAMETER"]; nice = (string)h["YOURPARAMETER"]; Assert.AreEqual("A", a, "Link tag (A)"); Assert.AreEqual("http://www.iki.fi/kaila", href, "href value"); Assert.AreEqual("", myValue, "myparameter value"); Assert.AreEqual("Kaarle Kaaila", nice, "yourparameter value"); if (!(node is LinkTag)) { // linkscanner has eaten up this piece Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; snode = (StringNode)node; Assert.AreEqual(snode.Text, "Kaarle's homepage", "Value of element"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; etag = (EndTag)node; Assert.AreEqual(etag.Text, "A", "endtag of link"); } // testing rest Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; tag = (Tag)node; Assert.AreEqual(tag.Text, "p", "following paragraph begins"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; snode = (StringNode)node; Assert.AreEqual(snode.Text, "Paragraph", "paragraph contents"); Assert.IsTrue(en.MoveNext()); node = (Node)en.Current; etag = (EndTag)node; Assert.AreEqual(etag.Text, "p", "paragraph endtag"); } catch (System.InvalidCastException) { Assert.Fail("Bad class element = " + node.GetType().FullName); } }