Пример #1
0
        public void TestImportFeedlist()
        {
            RssParser handler = new RssParser(APP_NAME);

            handler.LoadFeedlist(BASE_URL + "FeedList03Feeds.xml", null);
            Assertion.Assert("Feeds should be valid!", handler.FeedsListOK);
            Assertion.AssertEquals("FeedList03Feeds.xml should contain 3 feeds. Hence the name.", 3, handler.FeedsTable.Count);

            //Now import a feed list.
            using (FileStream stream = File.OpenRead(Path.Combine(WEBROOT_PATH, @"RssParserTestFiles\FeedList04Feeds.xml")))
            {
                handler.ImportFeedlist(stream);
                stream.Close();
            }
            Assertion.AssertEquals("3 + 4 = 7.  7 Feeds expected.", 7, handler.FeedsTable.Count);

            Assertion.AssertEquals("MSDN: Visual C#", handler.FeedsTable["http://msdn.microsoft.com/vcsharp/rss.xml"].title);
            Assertion.AssertEquals("Development", handler.FeedsTable["http://msdn.microsoft.com/vcsharp/rss.xml"].category);
            Assertion.AssertEquals("ASP.NET Forums: Architecture", handler.FeedsTable["http://www.asp.net/Forums/rss.aspx?forumid=16"].title);
            Assertion.AssertEquals("Forums", handler.FeedsTable["http://www.asp.net/Forums/rss.aspx?forumid=16"].category);
            Assertion.AssertEquals("Slashdot", handler.FeedsTable["http://slashdot.org/slashdot.rss"].title);
            Assertion.AssertEquals("News Technology", handler.FeedsTable["http://slashdot.org/slashdot.rss"].category);
            Assertion.AssertEquals("Torsten's .NET Blog", handler.FeedsTable["http://www.rendelmann.info/blog/SyndicationService.asmx/GetRss"].title);
            Assertion.AssertEquals("Blogs", handler.FeedsTable["http://www.rendelmann.info/blog/SyndicationService.asmx/GetRss"].category);
            Assertion.AssertEquals("you've been HAACKED", handler.FeedsTable["http://haacked.com/Rss.aspx"].title);
            Assertion.AssertEquals("Blogs", handler.FeedsTable["http://haacked.com/Rss.aspx"].category);
            Assertion.AssertEquals("kuro5hin.org", handler.FeedsTable["http://www.kuro5hin.org/backend.rdf"].title);
            Assertion.AssertEquals("News Technology", handler.FeedsTable["http://www.kuro5hin.org/backend.rdf"].category);
            Assertion.AssertEquals("Dare Obasanjo aka Carnage4Life", handler.FeedsTable["http://www.25hoursaday.com/weblog/SyndicationService.asmx/GetRss"].title);
            Assertion.AssertEquals("Blogs Microsoft", handler.FeedsTable["http://www.25hoursaday.com/weblog/SyndicationService.asmx/GetRss"].category);
        }
Пример #2
0
        public void TestImportFeedListWithDuplicate()
        {
            //Start by loading 3 feeds.
            RssParser handler = new RssParser(APP_NAME);

            handler.LoadFeedlist(BASE_URL + "FeedList03Feeds.xml", null);
            Assertion.Assert("Feeds should be valid!", handler.FeedsListOK);
            Assertion.AssertEquals("FeedList03Feeds.xml should contain 3 feeds. Hence the name.", 3, handler.FeedsTable.Count);

            // Now import a feed list that contains 1 new feed
            // and one that already exists.
            using (FileStream stream = File.OpenRead(Path.Combine(WEBROOT_PATH, @"RssParserTestFiles\FeedListWithDuplicateFrom03.xml")))
            {
                handler.ImportFeedlist(stream);
                stream.Close();
            }

            Assertion.AssertEquals("3 + 1 = 4.  4 Feeds expected because one is a duplicate!", 4, handler.FeedsTable.Count);

            Assertion.AssertEquals("MSDN: Visual C#", handler.FeedsTable["http://msdn.microsoft.com/vcsharp/rss.xml"].title);
            Assertion.AssertEquals("Development", handler.FeedsTable["http://msdn.microsoft.com/vcsharp/rss.xml"].category);
            Assertion.AssertEquals("ASP.NET Forums: Architecture", handler.FeedsTable["http://www.asp.net/Forums/rss.aspx?forumid=16"].title);
            Assertion.AssertEquals("Forums", handler.FeedsTable["http://www.asp.net/Forums/rss.aspx?forumid=16"].category);
            Assertion.AssertEquals("Slashdot", handler.FeedsTable["http://slashdot.org/slashdot.rss"].title);
            Assertion.AssertEquals("News Technology", handler.FeedsTable["http://slashdot.org/slashdot.rss"].category);
            Assertion.AssertEquals("Channel 9", handler.FeedsTable["http://channel9.msdn.com/rss.aspx"].title);
            Assertion.AssertEquals("Microsoft", handler.FeedsTable["http://channel9.msdn.com/rss.aspx"].category);
        }
Пример #3
0
        public void TestLoadFeeds()
        {
            RssParser handler = new RssParser(APP_NAME);

            handler.LoadFeedlist(BASE_URL + "FeedList03Feeds.xml", null);
            Assertion.Assert("Feeds should be valid!", handler.FeedsListOK);
            Assertion.AssertEquals("FeedList03Feeds.xml should contain 3 feeds. Hence the name.", 3, handler.FeedsTable.Count);

            //Assert the titles of the three feeds.
            Assertion.AssertEquals("MSDN: Visual C#", handler.FeedsTable["http://msdn.microsoft.com/vcsharp/rss.xml"].title);
            Assertion.AssertEquals("ASP.NET Forums: Architecture", handler.FeedsTable["http://www.asp.net/Forums/rss.aspx?forumid=16"].title);
            Assertion.AssertEquals("Slashdot", handler.FeedsTable["http://slashdot.org/slashdot.rss"].title);
        }
Пример #4
0
        public void TestRecentlyViewed()
        {
            //Load feed list.
            CacheManager cache   = new FileCacheManager(CACHE_DIR, TimeSpan.MaxValue);
            RssParser    handler = new RssParser(APP_NAME, cache);

            handler.LoadFeedlist(BASE_URL + "LocalTestFeedList.xml", null);
            Assertion.Assert("Feeds should be valid!", handler.FeedsListOK);

            //Grab a feed.
            feedsFeed feed = handler.FeedsTable["http://localhost/RssHandlerTestFiles/LocalTestFeed.xml"];

            //TODO: FeedInfo feedInfo = handler.GetFeedInfo(feed.link);
            //Assertion.AssertNotNull(feedInfo);
            //cache.SaveFeed(feedInfo);

            Assertion.AssertEquals("Rss Bandit Unit Test Feed", feed.title);
            Assertion.AssertEquals(1, feed.storiesrecentlyviewed.Count);

            //Grab feed items
            ArrayList items = handler.GetItemsForFeed(feed);

            Assertion.AssertEquals(2, items.Count);

            //The first one should have been read. the second not.
            NewsItem item = (NewsItem)items[0];

            Assertion.Assert(item.BeenRead);
            item = (NewsItem)items[1];
            Assertion.Assert(!item.BeenRead);

            //So let's read the second item.
            handler.MarkAllCachedItemsAsRead(feed);
            handler.ApplyFeedModifications(feed.link);

            //Let's save this guy.
            using (FileStream newFeedStream = File.OpenWrite(Path.Combine(WEBROOT_PATH, @"RssParserTestFiles\LocalTestFeedList_NEW.xml")))
            {
                //TODO: Ask Dare about RssParser.SaveFeedList()
                //handler.SaveFeedList(newFeedStream, RssFeedListFormat.RssParser);
                newFeedStream.Close();
                Assertion.Assert(File.Exists(Path.Combine(WEBROOT_PATH, @"RssParserTestFiles\LocalTestFeedList_NEW.xml")));
            }

            //Let's reload and see what happens.
            handler = new RssParser(APP_NAME, cache);
            handler.LoadFeedlist(BASE_URL + "LocalTestFeedList_NEW.xml", null);
            feed = handler.FeedsTable["http://localhost/RssHandlerTestFiles/LocalTestFeed.xml"];
            Assertion.AssertEquals("Should be two now.", 2, feed.storiesrecentlyviewed.Count);
        }
Пример #5
0
        public void TestLoadNonExistentFeed()
        {
            RssParser handler = new RssParser(APP_NAME);

            handler.LoadFeedlist(BASE_URL + "ThisFeedDoesNotExist.xml", null);
        }