예제 #1
0
        public void TestFetchingRssFeed()
        {
            Console.WriteLine("Test to check if fetching a rss feed works.");
            bool wait = true;
            Rss  feed = new Rss("http://www.voyagerproject.org/feed/");

            feed.FeedUpdated += delegate(Rss updated_feed)
            {
                Console.WriteLine("");
                Console.WriteLine("Rss Feed fetched (" + updated_feed.Channels.Count + ")");
                wait = false;
            };
            feed.FetchFeed();
            Console.WriteLine("Waiting for data");
            DateTime start = DateTime.Now;

            while (wait)
            {
                if (DateTime.Now - start > new TimeSpan(0, 0, 35))
                {
                    Console.WriteLine("");
                    Console.WriteLine("Operation took too long");
                    wait = false;
                    Assert.Fail("Operation took too long");
                }
                Console.Write(".");
                System.Threading.Thread.Sleep(250);
            }
            Assert.IsTrue(feed.Channels.Count > 0, "no channels found.");
            Console.WriteLine("Fetching Rss Feed Test successful.");
        }
        private void FeedUpdated(Rss feed)
        {
            ItemsView.Items.Clear();
            ListViewItem top_item = new ListViewItem(Title);

            //view_item.Text = Title;
            top_item.IndentCount = 0;
            //view_item.ToolTipText = Title;
            //view_item.ImageIndex = ;
            ItemsView.Items.Add(top_item);

            int items_num = 0;

            foreach (Rss.Channel channel in Feed.Channels)
            {
                foreach (Rss.Channel.Item item in channel.Items)
                {
                    ListViewItem view_item = new ListViewItem(item.Title);
                    //view_item.Text = item.Title;
                    view_item.Tag         = item;
                    view_item.ToolTipText = item.Description;
                    view_item.ImageIndex  = 1;
                    ItemsView.Items.Add(view_item);
                    items_num++;
                    if (items_num >= max_items)
                    {
                        return;
                    }
                }
            }
            //columnHeader1.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            columnHeader1.Width = -2;
        }
예제 #3
0
        public void TestUpdatingRssFeed()
        {
            Console.WriteLine("Test to check if updating a rss feed works.");
            bool wait      = true;
            int  items_num = 0;
            int  updates   = 0;
            Rss  feed      = new Rss("http://www.voyagerproject.org/feed/");

            feed.FeedUpdated += delegate(Rss updated_feed)
            {
                updates++;
                Console.WriteLine("");
                Console.WriteLine("Rss Feed fetched (" + updated_feed.Channels.Count + ")");
                items_num = updated_feed.Channels[0].Items.Count;
                updated_feed.FetchFeed();
                //wait = false;
            };
            feed.FetchFeed();
            Console.WriteLine("Waiting for data");
            DateTime start = DateTime.Now;

            while (wait)
            {
                if (DateTime.Now - start > new TimeSpan(0, 0, 2))
                {
                    Assert.IsTrue(feed.Channels.Count > 0, "no channels found.");
                    Assert.IsTrue(feed.Channels.Count == 1, "too many channels found.");
                    Assert.IsTrue(feed.Channels[0].Items.Count == items_num, "items num changed.");
                    wait = false;
                }
                Assert.IsTrue(updates <= 1, "too many updates.");
                Console.Write(".");
                System.Threading.Thread.Sleep(250);
            }
            Console.WriteLine("Updating Rss Feed Test successful.");
        }