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!"); } }
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); } }
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"); } }