public void ValidationTest() { // Default construction should pass. Assert.DoesNotThrow(() => this.uut.Validate()); // Null, empty, or whitespace command should fail. this.uut.Command = null; Assert.Throws <ValidationException>(() => this.uut.Validate()); this.uut = new UserListBotConfig(); this.uut.Command = string.Empty; Assert.Throws <ValidationException>(() => this.uut.Validate()); this.uut = new UserListBotConfig(); this.uut.Command = " "; Assert.Throws <ValidationException>(() => this.uut.Validate()); this.uut = new UserListBotConfig(); // Negative cooldown should fail. this.uut.Cooldown = -1; Assert.Throws <ValidationException>(() => this.uut.Validate()); this.uut = new UserListBotConfig(); // Zero cooldown should not. this.uut.Cooldown = 0;; Assert.DoesNotThrow(() => this.uut.Validate()); this.uut = new UserListBotConfig(); }
public void GoodConfigTest() { UserListBotConfig xmlConfig = XmlLoader.LoadConfig(Path.Combine(testFilesPath, "GoodConfig.xml")); Assert.AreEqual("!command", xmlConfig.Command); Assert.AreEqual(0, xmlConfig.Cooldown); }
public void EmptyValueTest() { UserListBotConfig defaultConfig = new UserListBotConfig(); UserListBotConfig xmlConfig = XmlLoader.LoadConfig(Path.Combine(testFilesPath, "BlankConfig.xml")); Assert.AreEqual(defaultConfig.Command, xmlConfig.Command); Assert.AreEqual(defaultConfig.Cooldown, xmlConfig.Cooldown); }
public void DefaultValueTest() { string path = Path.Combine(TestHelpers.PluginDir, "UserListBot", "Config", "SampleUserListBotConfig.xml"); UserListBotConfig defaultConfig = new UserListBotConfig(); UserListBotConfig xmlConfig = XmlLoader.LoadConfig(path); Assert.AreEqual(defaultConfig.Command, xmlConfig.Command); Assert.AreEqual(defaultConfig.Cooldown, xmlConfig.Cooldown); }
public void TestSetup() { this.uut = new UserListBotConfig(); }