Beispiel #1
0
        public void ShouldGetKarmaEntryNameFromReasonRequest(string request, string expected)
        {
            var    plugin = new KarmaPlugin();
            string result = plugin.ParseNameFromReasonRequest(request);

            Assert.Equal(expected, result);
        }
Beispiel #2
0
        private async IAsyncEnumerable <ResponseMessage> ReasonHandler(IncomingMessage message, IValidHandle matchedHandle)
        {
            var karmaEntryName  = _karmaPlugin.ParseNameFromReasonRequest(message.FullText);
            var numberRequested = _karmaPlugin.ParseNumberFromEndOfRequest(message.FullText);

            int reasonsCount = 0;

            foreach (var entry in _karmaRepositoryPlugin.GetReasons(karmaEntryName, numberRequested))
            {
                yield return(message.ReplyToChannel(_karmaPlugin.GenerateReasonMessage(entry)));

                reasonsCount++;
            }

            if (reasonsCount == 0)
            {
                yield return(message.ReplyToChannel($"No reasons found for {karmaEntryName}"));
            }
        }