Ejemplo n.º 1
0
        public void WhenGeneratingChangeRequest_ShouldNotIncludeOperator()
        {
            string expected = "test";
            var    plugin   = new KarmaPlugin();
            var    result   = plugin.ParseKarmaChangeWithReason("test++ for test");

            Assert.Equal(expected, result.Name);
        }
Ejemplo n.º 2
0
        public void WhenUsingNegativeKarmaOperator_ShouldHaveChangeAmoutNegativeOne()
        {
            var plugin = new KarmaPlugin();

            var result = plugin.ParseKarmaChangeWithReason("test-- for test");

            Assert.Equal(-1, result.Amount);
        }
Ejemplo n.º 3
0
        public void ShouldFillReasonField()
        {
            string expected = "for test";
            var    plugin   = new KarmaPlugin();

            var result = plugin.ParseKarmaChangeWithReason("test-- for test");

            Assert.Equal(expected, result.Reason);
        }
Ejemplo n.º 4
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));
            }
        }