public void ParseSection2()
        {
            // Start and End for tag
            HtmlSectionTemplate template = new HtmlSectionTemplate();

            template.Tags     = "T";
            template.Template =
                "<table><tr><td>Title:<#TITLE>(</td><td><#START></td><td><#DESCRIPTION></td><Z(><td><#GENRE></td></Z)?></tr></table>";

            HtmlSectionParser elements = new HtmlSectionParser(template);

            ParserData  data   = new ParserData();
            IParserData idata  = (IParserData)data;
            string      source = "<table><tr><td>Test</td><td>123</td><td>blah blah</td></tr></table>";

            elements.ParseSection(source, ref idata);

            Assert.IsTrue(data.GetElement("#TITLE") == "Test");
            Assert.IsTrue(data.GetElement("#START") == "123");
            Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");

            data   = new ParserData();
            idata  = (IParserData)data;
            source = "<table><tr><td>Title:Test(1:2)</td><td>123</td><td>blah blah</td></tr></table>";
            elements.ParseSection(source, ref idata);

            Assert.IsTrue(data.GetElement("#TITLE") == "Test");
            Assert.IsTrue(data.GetElement("#START") == "123");
            Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");
        }
        public void ParseSection3()
        {
            // Multiple tags
            HtmlSectionTemplate template = new HtmlSectionTemplate();

            template.Tags     = "T";
            template.Template =
                "<table><tr><td><#TITLE>-<#SUBTITLE></td><td><#START></td><td><#DESCRIPTION></td><Z(><td><#GENRE></td></Z)?></tr></table>";

            HtmlSectionParser elements = new HtmlSectionParser(template);
            ParserData        data     = new ParserData();
            IParserData       idata    = (IParserData)data;
            string            source   = "<table><tr><td>Test-Sub</td><td>123</td><td>blah blah</td></tr></table>";

            elements.ParseSection(source, ref idata);

            Assert.IsTrue(data.GetElement("#TITLE") == "Test");
            Assert.IsTrue(data.GetElement("#SUBTITLE") == "Sub");
            Assert.IsTrue(data.GetElement("#START") == "123");
            Assert.IsTrue(data.GetElement("#DESCRIPTION") == "blah blah");
        }
示例#3
0
 public HtmlSectionParserTests()
 {
     this.parser = new HtmlSectionParser();
 }