public void WhenChangeNegative_ShouldUseDownboat(string name, string reasonValue, string expected)
        {
            Reason reason = new Reason(name, -1, reasonValue);
            var    plugin = new KarmaPlugin();

            string result = plugin.GenerateReasonMessage(reason);

            Assert.Equal(expected, result);
        }
        public void ShouldReturnReason(string name, string reasonValue, string expected)
        {
            Reason reason = new Reason(name, 1, reasonValue);
            var    plugin = new KarmaPlugin();

            string result = plugin.GenerateReasonMessage(reason);

            Assert.Equal(expected, result);
        }
Esempio n. 3
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}"));
            }
        }