Esempio n. 1
0
 private async IAsyncEnumerable <ResponseMessage> ListHandler(IncomingMessage message, IValidHandle matchedHandle)
 {
     foreach (var entry in _karmaRepositoryPlugin.GetTop(_karmaPlugin.ParseNumberFromEndOfRequest(message.FullText)))
     {
         yield return(message.ReplyToChannel(_karmaPlugin.GenerateCurrentKarmaMessage(entry)));
     }
 }
        public void GivenReasonRequest_ShouldReturnNumber(string input, int expected)
        {
            var plugin = new KarmaPlugin();

            var result = plugin.ParseNumberFromEndOfRequest(input);

            Assert.Equal(expected, result);
        }
        public void WhenNoNumberGiven_ShouldDefaultToTen()
        {
            var input = "@termibot karma list";

            var plugin = new KarmaPlugin();
            int result = plugin.ParseNumberFromEndOfRequest(input);

            Assert.Equal(10, result);
        }
        public void WhenZeroGivenShouldReturnDefault()
        {
            var input = "@termibot karma list 0";

            var plugin = new KarmaPlugin();
            int result = plugin.ParseNumberFromEndOfRequest(input);

            Assert.Equal(10, result);
        }
        public void WhenNumberGiven_ShouldReturnNumber(string inputNumber, int expected)
        {
            var input = $"@termibot karma list {inputNumber}";

            var plugin = new KarmaPlugin();
            var result = plugin.ParseNumberFromEndOfRequest(input);

            Assert.Equal(expected, result);
        }