Exemple #1
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);
        }
 /// <summary>
 /// Returns the feed image url as provided within the feed XML.
 /// If there is no such element, null is returned. In case the feed image was
 /// yet retrived from the web and cached locally, a tweaked local file Url will
 /// be returned instead of the original Url.
 /// </summary>
 /// <param name="f">feedsFeed</param>
 /// <returns>string</returns>
 public string GetFeedImageUrl(feedsFeed f)
 {
     return(null);
 }
 /// <summary>
 /// Gets the favicon Image. If the feed does not have one or it was not yet
 /// fetched from the web, null is returned.
 /// </summary>
 /// <param name="f">feedsFeed</param>
 /// <returns>Image, or null</returns>
 public Image GetFavIcon(feedsFeed f)
 {
     return(null);
 }