コード例 #1
0
        public void ShouldNotReturnCommandIfIsNotWholeWord()
        {
            var    parser = new SlackCommandParser("scbot", "U123");
            string command;

            Assert.False(parser.TryGetCommand(new Message("a-channel", "a-user", "scbot untrack foo"), "track", out command));
        }
コード例 #2
0
        public void ShouldReturnFalseWhenNotMentioned()
        {
            var    parser = new SlackCommandParser("scbot", "U03JWF43N");
            string command;

            Assert.False(parser.TryGetCommand(new Message("a-channel", "a-user", "something irrelevant"), out command));
            Assert.Null(command);
        }
コード例 #3
0
        public void ShouldStillStripBotNameFromPMs()
        {
            var    parser = new SlackCommandParser("scbot", "U03JWF43N");
            string command;

            Assert.True(parser.TryGetCommand(new Message("D03JWF44C", "a-user", "scbot: do the thing"), out command));
            Assert.AreEqual("do the thing", command);
        }
コード例 #4
0
        public void ShouldReturnCommandWhenItContainsNewlines()
        {
            var    parser = new SlackCommandParser("scbot", "U03JWF43N");
            string command;

            Assert.True(parser.TryGetCommand(new Message("a-channel", "a-user", "<@U03JWF43N> do the \n\nthing"), out command));
            Assert.AreEqual("do the \n\nthing", command);
        }
コード例 #5
0
        public void ShouldNotReturnCommandWhenMentionedInMiddleOfMessage()
        {
            var    parser = new SlackCommandParser("scbot", "U03JWF43N");
            string command;

            Assert.False(parser.TryGetCommand(new Message("a-channel", "a-user", "I'm going to mention scbot in this message"), out command));
            Assert.Null(command);
        }
コード例 #6
0
        public void ShouldReturnCommandWhenMentionedAtStartOfMessage(string ping)
        {
            var    parser = new SlackCommandParser("scbot", "U03JWF43N");
            string command;

            Assert.True(parser.TryGetCommand(new Message("a-channel", "a-user", string.Format("{0} do the thing", ping)), out command));
            Assert.AreEqual("do the thing", command);
        }
コード例 #7
0
        public void ShouldAlwaysTreatPMsAsMentions()
        {
            // channel names that start with D are direct messages (or PMs) so the bot is always being addressed directly
            var    parser = new SlackCommandParser("scbot", "U03JWF43N");
            string command;

            Assert.True(parser.TryGetCommand(new Message("D03JWF44C", "a-user", "do the thing"), out command));
            Assert.AreEqual("do the thing", command);
        }