public void RssConfigValidateTest() { Feed feed1 = new Feed(); feed1.Url = RssBotTestHelpers.TestUrl1; feed1.RefreshInterval = TimeSpan.Zero + TimeSpan.FromTicks(1); // Positive is good. feed1.AddChannel(TestHelpers.GetTestIrcConfig().Channels[0]); Feed feed2 = new Feed(); feed2.Url = RssBotTestHelpers.TestUrl2; feed2.RefreshInterval = TimeSpan.MaxValue; feed2.AddChannel(TestHelpers.GetTestIrcConfig().Channels[0]); RssBotConfig config = new RssBotConfig(); // Empty list should fail. Assert.Throws <ValidationException>(() => config.Validate()); config.AddFeed(feed1); config.AddFeed(feed2); Assert.DoesNotThrow(() => config.Validate()); // Ensure things get cloned by changing feed 1, and validation should still pass. feed1.Url = null; Assert.DoesNotThrow(() => config.Validate()); // Now add bad feed 1, and we should fail validation. config.AddFeed(feed1); Assert.Throws <ValidationException>(() => config.Validate()); }
public void GoodConfigTest() { string rssConfig = Path.Combine( TestHelpers.PluginDir, "RssBot", "Config", "SampleRssBotConfig.xml" ); RssBotConfig config = XmlLoader.ParseConfig(rssConfig); Assert.AreEqual(RssBotTestHelpers.TestUrl1, config.Feeds[0].Url); Assert.AreEqual(RssBotTestHelpers.Interval1, config.Feeds[0].RefreshInterval); Assert.AreEqual(1, config.Feeds[0].Channels.Count); Assert.AreEqual("#MyChannel", config.Feeds[0].Channels[0]); Assert.AreEqual(RssBotTestHelpers.TestUrl2, config.Feeds[1].Url); Assert.AreEqual(RssBotTestHelpers.Interval2, config.Feeds[1].RefreshInterval); Assert.AreEqual(2, config.Feeds[1].Channels.Count); Assert.AreEqual("#MyChannel", config.Feeds[1].Channels[0]); Assert.AreEqual("#MyOtherChannel", config.Feeds[1].Channels[1]); }