Ejemplo n.º 1
0
        public void RssListSourceTest()
        {
            var sources = new RssSources(fileName);

            Assert.AreEqual(sources.Sources.Count, rssSourcesCount, $"Sources file count {sources.Sources.Count} != {rssSourcesCount}");
            foreach (var source in sources.Sources)
            {
                Console.WriteLine(source);
                Assert.IsTrue(source.Key is Object && source.Key.Length > 0, "Empty Company entry!");
                Assert.IsTrue(source.Value is Object && source.Value.Length > 0, "Empty Address entry!");
            }
        }
Ejemplo n.º 2
0
        public void RssFeedTest()
        {
            var sources = new RssSources(fileName);

            Assert.AreEqual(sources.Sources.Count, rssSourcesCount, $"Sources file count {sources.Sources.Count} != {rssSourcesCount}");
            foreach (var source in sources.Sources)
            {
                var uri = source.Value;
                using var feed = new RssFeed(uri);
                Assert.IsTrue(feed.Load());
                Assert.IsTrue(feed.PubDate > DateTimeOffset.MinValue);

                Console.WriteLine(feed);
            }
        }
Ejemplo n.º 3
0
        public void CalcAgeTest()
        {
            var sources = new RssSources(fileName);

            Assert.AreEqual(sources.Sources.Count, rssSourcesCount, $"Sources file count {sources.Sources.Count} != {rssSourcesCount}");

            foreach (var source in sources.Sources)
            {
                var uri = source.Value;
                using var feed = new RssFeed(uri);
                Assert.IsTrue(feed.Load());
                Assert.IsTrue(feed.PubDate > DateTimeOffset.MinValue);

                Console.WriteLine(feed);
            }

            using var aging = new CheckAge()
                  {
                      CurrentDateTime = DateTimeOffset.Now,
                      MaxAge          = TimeSpan.FromDays(2),
                      Feeds           = sources.Sources
                  };

            aging.Check();

            var companyEnum = sources.Sources.Keys.GetEnumerator();

            foreach (var isOverAge in aging.OverAge)
            {
                string companyName = "<unknown>";
                if (companyEnum.MoveNext())
                {
                    companyName = companyEnum.Current;
                }
                Console.WriteLine($"\"{companyName}\" RSS Feed is{(isOverAge?" ":" not ")}over {aging.MaxAge.Days} days");
            }
        }