public void Misc() { TestParser parser = new TestParser(CreateRootState()); parser.Parse(@" <doc> <!DOCTYPE $ > <![CDATA[ ] $ ] ]]> <!-- <foo> <bar arg=""> $ --> </doc> ", delegate { parser.AssertStateIs <XmlDocTypeState> (); parser.AssertNodeDepth(3); parser.AssertPath("//doc/<!DOCTYPE>"); }, delegate { parser.AssertStateIs <XmlCDataState> (); parser.AssertNodeDepth(3); parser.AssertPath("//doc/<![CDATA[ ]]>"); }, delegate { parser.AssertStateIs <XmlCommentState> (); parser.AssertNodeDepth(3); parser.AssertPath("//doc/<!-- -->"); } ); parser.AssertEmpty(); parser.AssertErrorCount(0); }
public void Unclosed() { TestParser parser = new TestParser(CreateRootState()); parser.Parse(@" <doc> <tag.a> <tag.b><tag.b>$ </tag.a>$ </doc> ", delegate { parser.AssertStateIs <XmlFreeState> (); parser.AssertNodeDepth(5); parser.AssertPath("//doc/tag.a/tag.b/tag.b"); }, delegate { parser.AssertStateIs <XmlFreeState> (); parser.AssertNodeDepth(2); parser.AssertPath("//doc"); } ); parser.AssertEmpty(); parser.AssertErrorCount(2); }
public void TestAutoClosing() { TestParser parser = new TestParser(CreateRootState()); parser.Parse(@" <html> <body> <p><img>$ <p><div> $ </div> <p> <p><a href =""http://mono-project.com/"" ><b>foo $ </a> <p> <p>$ </body> </html> ", delegate { parser.AssertPath("//html/body/p"); }, delegate { parser.AssertPath("//html/body/div"); }, delegate { parser.AssertPath("//html/body/p/a/b"); }, delegate { parser.AssertPath("//html/body/p"); } ); parser.AssertEmpty(); parser.AssertErrorCount(8); }
public void TestHtmlImplicitClosing() { TestParser parser = new TestParser(CreateRootState()); parser.Parse(@" <html> <body> <li><li>$ <dt><img><dd>$</dd> <tr><tr>$</tr></li> <p> <table>$</table> <td><th><td>$ </body> </html> ", delegate { parser.AssertPath("//html/body/li"); }, delegate { parser.AssertPath("//html/body/li/dd"); }, delegate { parser.AssertPath("//html/body/li/tr"); }, delegate { parser.AssertPath("//html/body/table"); }, delegate { parser.AssertPath("//html/body/td"); } ); parser.AssertEmpty(); parser.AssertErrorCount(1); }
public void IncompleteTags() { TestParser parser = new TestParser(CreateRootState()); parser.Parse(@" <doc> <tag.a att1 > <tag.b att2="" > <tag.c att3 = ' <tag.d att4 = > <tag.e att5='' att6=' att7 = > <tag.f id='$foo' /> </tag.e> </tag.d> </tag.c> </tag.b> </tag.a> </doc> ", delegate { parser.AssertStateIs <XmlSingleQuotedAttributeValueState> (); parser.AssertNodeDepth(9); parser.AssertPath("//doc/tag.a/tag.b/tag.c/tag.d/tag.e/tag.f/@id"); } ); parser.AssertEmpty(); parser.AssertErrorCount(3, x => x.ErrorType == ErrorType.Error); parser.AssertErrorCount(2, x => x.ErrorType == ErrorType.Warning); }
public void AttributeName() { TestParser parser = new TestParser(CreateRootState()); parser.Parse(@" <doc> <tag.a> <tag.b id=""$foo"" /> </tag.a> </doc> ", delegate { parser.AssertStateIs <XmlDoubleQuotedAttributeValueState> (); parser.AssertPath("//doc/tag.a/tag.b/@id"); } ); parser.AssertEmpty(); parser.AssertErrorCount(0); }