/// <summary>
        /// Loads the url's from the SiteList
        /// </summary>
        /// <exception cref="RSSLib.RSSControllerException">Throws an exception when SiteList is not found.</exception>
        public List <RssFeed> LoadRssFeeds()
        {
            List <RssFeed> lstResult        = new List <RssFeed>();
            List <string>  lstFeedLocations = new List <string>();

            try
            {
                lstFeedLocations = _fileController.LoadRowsFromFile(this.PathSiteList);
            }
            catch (FileNotFoundException ex)
            {
                throw new RssControllerException("SiteList was not found on the specified location: " + ex.FileName);
            }
            foreach (string strFeedLocation in lstFeedLocations)
            {
                lstResult.Add(new RssFeed(_xmlController.GetTitleFromRssFeed(strFeedLocation), strFeedLocation));
            }
            return(lstResult);
        }//end LoadRssFeeds
Example #2
0
        public void GetRssItemsFromFeed_GuidCacheIsOnlyLoadedFirstTime_True()
        {
            MockRepository  mocks           = new MockRepository();
            IFileController iFileController = mocks.StrictMock <IFileController>();
            IXmlController  iXmlController  = mocks.Stub <IXmlController>();
            List <string>   lstGuidItems    = new List <string>();

            lstGuidItems.Add("GuidItem1");
            lstGuidItems.Add("GuidItem2");

            List <RSSLib.Model.RssItem> lstRssItems = new List <RSSLib.Model.RssItem>();

            lstRssItems.Add(new RSSLib.Model.RssItem {
                Title = "Item1", Guid = "GuidItem1", Link = "LinkItem1"
            });
            lstRssItems.Add(new RSSLib.Model.RssItem {
                Title = "Item2", Guid = "GuidItem2", Link = "LinkItem2"
            });

            using (mocks.Record())
            {
                //The first time we call the GetRssItemsFromFeed the following thow methods will be called form our mock
                Expect.Call(iFileController.LoadRowsFromFile(_rssController.PathGuidCache)).Return(lstGuidItems);
                Expect.Call(iXmlController.GetRssItemsFromFeed("FakeRssLocation")).Return(lstRssItems);
                //The second time we call the GetRssItemsFromFeed, only on method will be called (the cache doesn't need to be loaded from the files
                //system because it is cashed already.
                Expect.Call(iXmlController.GetRssItemsFromFeed("FakeRssLocation")).Return(lstRssItems);
            }
            _rssController.FileController = iFileController;
            _rssController.XmlController  = iXmlController;
            _rssController.GetRssItemsFromFeed(new RSSLib.Model.RssFeed {
                Title = "APO Test", Location = "FakeRssLocation"
            });
            _rssController.GetRssItemsFromFeed(new RSSLib.Model.RssFeed {
                Title = "APO Test", Location = "FakeRssLocation"
            });
            mocks.VerifyAll();
        }
Example #3
0
        public void LoadRssFeeds_CorrectInputWithMock_ReturnsRssFeed()
        {
            MockRepository  mocks           = new MockRepository();
            IXmlController  iXmlController  = mocks.DynamicMock <IXmlController>();
            IFileController iFileController = mocks.Stub <IFileController>();

            List <string> lstFeed = new List <string>();

            lstFeed.Add("FakeRssLocation");

            using (mocks.Record())
            {
                Expect.Call(iFileController.LoadRowsFromFile(_rssController.PathSiteList)).Return(lstFeed);
                //you can write the statement above in two statements if you want:
                //Expect.Call(iFileController.LoadRowsFromFile(_rssController.PathSiteList));
                //LastCall.Return(lstFeed);
                Expect.Call(iXmlController.GetTitleFromRssFeed(lstFeed[0])).Return("APO RSS");
            }//end mocks.Record
            _rssController.FileController = iFileController;
            _rssController.XmlController  = iXmlController;
            List <RSSLib.Model.RssFeed> lstResult = _rssController.LoadRssFeeds();

            mocks.VerifyAll();
        }