Пример #1
0
 public void TestExtract()
 {
     const string html = "<b>first</b><b>second</b>";
     string str = BotUtil.Extract(html, "<b>", "</b>", 0);
     Assert.AreEqual("first", str);
     str = BotUtil.Extract(html, "<b>", "</b>", 2);
     Assert.AreEqual("second", str);
     str = BotUtil.Extract(html, "bad", "</b>", 0);
     Assert.IsNull(str);
     str = BotUtil.Extract(html, "<b>", "bad", 0);
     Assert.IsNull(str);
 }
Пример #2
0
 public void TestLoadPage()
 {
     // test good web site
     string str = BotUtil.LoadPage(new Uri("http://www.httprecipes.com/"));
     Assert.IsTrue(str.IndexOf("Recipes") != -1);
     // test bad website
     try
     {
         BotUtil.LoadPage(new Uri("http://www.httprecipes.com/sdhfuishdfui"));
         Assert.IsFalse(true);
     }
     catch (Exception)
     {
         Assert.IsTrue(true);
     }
 }