Beispiel #1
0
        public void canCompareFeeds()
        {
            var IdY = Guid.NewGuid();
            var IdZ = Guid.NewGuid();

            var feed1 = new Feed() { Id = IdZ, Name = "Feed X" };
            var feed2 = new Feed() { Id = IdZ, Name = "Feed Y" };
            var feed3 = new Feed() { Id = IdY, Name = "Feed Z" };

            Assert.IsTrue(feed1.Equals(feed2), "Object.Equals() false negative for Feed");
            Assert.IsFalse(feed1.Equals(feed3), "Object.Equals() false positive for Feed");

            Assert.IsFalse(feed2 == feed3, "== operator overload false positive for feed");
            Assert.IsTrue(feed2 != feed3, "== operator overload false negative for feed");
            Assert.IsTrue(feed1 != feed3, "!= operator overload false positive for feed");
            Assert.IsFalse(feed1 != feed2, "!= operator overload false negative for feed");

            //Assert.IsFalse(feed1.Equals(new Object(), "false positive comparing feed to object");
        }
        private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs, Feed feed)
        {
            var rssReader = new RssReader();
            var newFeedItems = rssReader.ReadFeedItems(feed.Url);

            foreach (var f in AllFeeds)
            {
                if (feed.Equals(f))
                {
                    var i = newFeedItems.Count - f.CollectionFeedItems.Count;
                    f.CollectionFeedItems = new List<IFeedItem>(newFeedItems);
                    MessageBox.Show(i + " new episodes for " + f.Title);
                }
            }
        }