예제 #1
0
        public void ShouldNotMatchInvalidInputs(string input)
        {
            int expected = 0;
            var plugin   = new KarmaPlugin();

            var matches         = plugin.GetMessageMatches(input);
            int numberOfMatches = matches.Count;

            Assert.Equal(expected, numberOfMatches);
        }
예제 #2
0
        private IEnumerable <ResponseMessage> KarmaHandler(IncomingMessage message, IValidHandle matchedHandle)
        {
            var matches = _karmaPlugin.GetMessageMatches(message.FullText);

            foreach (Match match in matches)
            {
                var changeRequest = _karmaPlugin.ParseKarmaChange(match.Value);
                yield return(HandleKarmaChange(message, changeRequest));
            }
        }
예제 #3
0
        public void ShouldMatchValidInputs(string input)
        {
            int expected = 1;
            var plugin   = new KarmaPlugin();

            var matches         = plugin.GetMessageMatches(input);
            int numberOfMatches = matches.Count;

            Assert.Equal(expected, numberOfMatches);
            output.WriteLine($"Matched {matches[0].Value}");
        }
예제 #4
0
        public void GivenWhitespace_ShouldOnlyMatchCharacters()
        {
            int expectedCount      = 1;
            var expectedMatchvalue = "test++";
            var plugin             = new KarmaPlugin();

            var matches         = plugin.GetMessageMatches(" test++ ");
            int numberOfMatches = matches.Count;

            Assert.Equal(expectedCount, numberOfMatches);
            Assert.Equal(expectedMatchvalue, matches[0].Value);
        }
예제 #5
0
        public void GivenHyphenatedPhrase_ShouldTreatNormally()
        {
            int expectedCount         = 2;
            var expectedMatchvalueOne = "hyphenated-word--";
            var expectedMatchvalueTwo = "part-time-teachers++";
            var plugin = new KarmaPlugin();

            var matches         = plugin.GetMessageMatches("hyphenated-word-- part-time-teachers++");
            int numberOfMatches = matches.Count;

            Assert.Equal(expectedCount, numberOfMatches);
            Assert.Equal(expectedMatchvalueOne, matches[0].Value);
            Assert.Equal(expectedMatchvalueTwo, matches[1].Value);
        }
예제 #6
0
        public void GivenAdditionalPlusesOrMinnuses_ShouldMatchOnlyTwo()
        {
            int expectedCount         = 4;
            var expectedMatchvalueOne = "test++";
            var expectedMatchvalueTwo = "test--";
            var plugin = new KarmaPlugin();

            var matches         = plugin.GetMessageMatches("test+++ test++++++++++ test--- test----------");
            int numberOfMatches = matches.Count;

            Assert.Equal(expectedCount, numberOfMatches);
            Assert.Equal(expectedMatchvalueOne, matches[0].Value);
            Assert.Equal(expectedMatchvalueOne, matches[1].Value);
            Assert.Equal(expectedMatchvalueTwo, matches[2].Value);
            Assert.Equal(expectedMatchvalueTwo, matches[3].Value);
        }