public void GoodFileTest() { string goodFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "GoodFile.xml"); try { // Need to do this since we need a run-time value for the exe path. File.WriteAllText(goodFile, xmlString); CowSayBotConfig config = XmlLoader.LoadCowSayBotConfig(goodFile); Assert.AreEqual(@"!{%saycmd%} (?<msg>.+)", config.ListenRegex); Assert.AreEqual(cowsayLocation, config.ExeCommand); Assert.AreEqual(5, config.CoolDownTimeSeconds); Assert.AreEqual(5, config.CowFileInfoList.CommandList.Count); Assert.AreEqual("DEFAULT", config.CowFileInfoList.CommandList["cowsay"]); Assert.AreEqual("vader", config.CowFileInfoList.CommandList["vadersay"]); Assert.AreEqual("tux", config.CowFileInfoList.CommandList["tuxsay"]); Assert.AreEqual("moose", config.CowFileInfoList.CommandList["moosesay"]); Assert.AreEqual("moofasa", config.CowFileInfoList.CommandList["lionsay"]); } finally { if (File.Exists(goodFile)) { File.Delete(goodFile); } } }
public void GoodFileTest() { string goodFile = Path.Combine(TestFilesPath, "GoodFile.xml"); CowSayBotConfig config = XmlLoader.LoadCowSayBotConfig(goodFile); Assert.AreEqual(@"!{%saycmd%} (?<msg>.+)", config.ListenRegex); Assert.AreEqual("../../Plugins/CowSayBot/TestFiles/cowsay", config.ExeCommand); Assert.AreEqual(5, config.CoolDownTimeSeconds); Assert.AreEqual(5, config.CowFileInfoList.CommandList.Count); Assert.AreEqual("DEFAULT", config.CowFileInfoList.CommandList["cowsay"]); Assert.AreEqual("vader", config.CowFileInfoList.CommandList["vadersay"]); Assert.AreEqual("tux", config.CowFileInfoList.CommandList["tuxsay"]); Assert.AreEqual("moose", config.CowFileInfoList.CommandList["moosesay"]); Assert.AreEqual("moofasa", config.CowFileInfoList.CommandList["lionsay"]); }
public void FileNotFoundTest() { Assert.Throws <FileNotFoundException>(() => XmlLoader.LoadCowSayBotConfig("derp.xml")); }