示例#1
0
 public void TestNullPost()
 {
     FileStream file = new FileStream("Data/post2.json", FileMode.Open);
     var parser = new DZPostParser(file);
     var data = parser.GetData();
     var p = data.Items[3][0];
     Assert.IsNull(p);
 }
示例#2
0
 public void TestParseAttachment()
 {
     FileStream file = new FileStream("Data/post2.json", FileMode.Open);
     var parser = new DZPostParser(file);
     var data = parser.GetData();
     var p = data.Items[10][2];
     Assert.AreEqual("img", p.Descendants().Last().Name);
 }
示例#3
0
        public void TestParseThread()
        {
            FileStream file = new FileStream("Data/post.json", FileMode.Open);
            var parser = new DZPostParser(file);
            var data = parser.GetData();
            var content = data.Items[0];

        }
示例#4
0
 public void TestParseError()
 {
     FileStream file = new FileStream("Data/error.json", FileMode.Open);
     try
     {
         var parser = new DZPostParser(file).GetData();
         Assert.Fail("There should be an exception");
     }
     catch (Exception e)
     {
         Assert.AreEqual("要淡定", e.Message);
     }
 }
示例#5
0
        public void TestReGroupContent()
        {
            FileStream file = new FileStream("Data/post.json", FileMode.Open);
            var parser = new DZPostParser(file);
            var data = parser.GetData();
            var content = data.Items[0];
            Assert.AreEqual(47, content.Count());
            Assert.AreEqual(1, content.First().Descendants().Count());
            Assert.AreEqual(0, content.ElementAt(1).Descendants().Count());
            Assert.AreEqual(0, content.ElementAt(3).Descendants().Count());

            var blockquote = data.Items[4].First().Element();
            Assert.AreEqual("blockquote", blockquote.Name);
            Assert.AreEqual(2, blockquote.Children.Count);
        }