示例#1
0
        public void ValidateBadListenRegexTest()
        {
            CowSayBotConfig uut = new CowSayBotConfig();

            uut.ListenRegex = null;
            uut.ExeCommand  = FakeExe;
            uut.CowFileInfoList.CommandList["command"] = "name";

            Assert.Throws <InvalidOperationException>(() => uut.Validate());

            uut.ListenRegex = string.Empty;
            Assert.Throws <InvalidOperationException>(() => uut.Validate());

            uut.ListenRegex = "       ";
            Assert.Throws <InvalidOperationException>(() => uut.Validate());
        }
示例#2
0
        public void ValidateBadCowFileInfoListTest()
        {
            CowSayBotConfig uut = new CowSayBotConfig();

            uut.ListenRegex = @"^!{%saycmd%} (?<msg>.+)";
            uut.ExeCommand  = FakeExe;
            uut.CowFileInfoList.CommandList.Clear();

            Assert.Throws <InvalidOperationException>(() => uut.Validate());
        }
示例#3
0
        public void ValidateBadExeCommandTest()
        {
            CowSayBotConfig uut = new CowSayBotConfig();

            uut.ListenRegex = @"^!{%saycmd%} (?<msg>.+)";
            uut.ExeCommand  = null;
            uut.CowFileInfoList.CommandList["command"] = "name";

            Assert.Throws <InvalidOperationException>(() => uut.Validate());

            uut.ExeCommand = string.Empty;
            Assert.Throws <InvalidOperationException>(() => uut.Validate());

            uut.ExeCommand = "       ";
            Assert.Throws <InvalidOperationException>(() => uut.Validate());

            uut.ExeCommand = "doesNotExist";
            Assert.Throws <InvalidOperationException>(() => uut.Validate());
        }
示例#4
0
        public void ValidateSuccessTest()
        {
            CowSayBotConfig uut = new CowSayBotConfig();

            uut.ListenRegex = @"^!{%saycmd%} (?<msg>.+)";
            uut.ExeCommand  = FakeExe;
            uut.CowFileInfoList.CommandList["command"] = "name";

            Assert.DoesNotThrow(() => uut.Validate());
        }