Example #1
0
        public void ShouldNotMatchInvalidReasonInputs(string input)
        {
            int expectedCount = 0;
            var plugin        = new KarmaPlugin();

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

            Assert.Equal(expectedCount, numberOfMatches);
        }
Example #2
0
        public void ShouldMatchValidReasonInputs(string input, string expectedMatch)
        {
            int expectedCount = 1;
            var plugin        = new KarmaPlugin();

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

            Assert.Equal(expectedCount, numberOfMatches);
            Assert.Equal(expectedMatch, matches[0].Value);
        }
Example #3
0
        private async IAsyncEnumerable <ResponseMessage> KarmaHandler(IncomingMessage message, IValidHandle matchedHandle)
        {
            var operatorMatches = _karmaPlugin.GetOperatorMatchesInMessage(message.FullText);
            var reasonMatches   = _karmaPlugin.GetReasonMatchesInMessage(message.FullText);

            operatorMatches = operatorMatches.Where(x => reasonMatches.All(y => y.Index != x.Index)).ToList();

            foreach (Match match in operatorMatches)
            {
                var changeRequest = _karmaPlugin.ParseKarmaChange(match.Value);
                yield return(HandleKarmaChange(message, changeRequest));
            }
            foreach (Match match in reasonMatches)
            {
                var changeRequest = _karmaPlugin.ParseKarmaChangeWithReason(match.Value);
                yield return(HandleKarmaChange(message, changeRequest));
            }
        }