Esempio n. 1
0
        public void canUpdateOldFeed()
        {
            var testFeed = new Feed() { Id = Guid.NewGuid(), Url = "http://rss.acast.com/ensvensktiger" };
            testFeed.update();

            var numberOfItemsToRemove = 3;
            var numberOfItems = testFeed.Items.Count;

            Assert.IsTrue(numberOfItems > numberOfItemsToRemove, "The feed contain less Items than we want to remove.");

            var removedItems = new FeedItem[numberOfItemsToRemove];
            while(numberOfItemsToRemove > 0)
            {
                removedItems[numberOfItemsToRemove - 1] = testFeed.Items[testFeed.Items.Count - 1];
                testFeed.Items.Remove(removedItems[numberOfItemsToRemove - 1]);
                numberOfItemsToRemove--;
            }
            Assert.IsTrue(testFeed.Items.Count == numberOfItems - removedItems.Length, "Testmethod did not remove correct number of items");
            foreach (FeedItem item in removedItems)
                Assert.IsFalse(testFeed.Items.Contains(item), "Removed item still in testItem");

            testFeed.LastFetchedFromServer = default(DateTime);
            testFeed.update();
            Assert.IsTrue(testFeed.Items.Count == numberOfItems, "Feed items should be as many as they were before update");
            foreach (FeedItem item in removedItems)
                Assert.IsTrue(testFeed.Items.Contains(item), "The removed item should have been put back into the feed after update");
        }
Esempio n. 2
0
        public void canUpdateNewFeed()
        {
            var newFeed = new Feed() { Id = Guid.NewGuid(), Url = "http://rss.acast.com/ensvensktiger" };

            Assert.IsTrue(newFeed.LastFetchedFromServer == default(DateTime), "LastFetchFromServer not null for new Feed");
            Assert.IsNull(newFeed.Items, "Items not null for new Feed");
            Assert.IsTrue(newFeed.LastUpdateOnServer == default(DateTime), "LastUpdateOnServer not null for new Feed");
            Assert.IsNull(newFeed.Name, "Name not null for new Feed");

            newFeed.update();

            Assert.IsNotNull(newFeed.LastFetchedFromServer, "LastFetchFromServer is null for updated Feed");
            Assert.IsNotNull(newFeed.Items, "Items is null for updated Feed");
            Assert.IsNotNull(newFeed.LastUpdateOnServer, "LastUpdateOnServer is null for updated Feed");
        }