public void WhenUsingNegativeKarmaOperator_ShouldHaveChangeAmoutNegativeOne() { var plugin = new KarmaPlugin(); var result = plugin.ParseKarmaChange("test--"); Assert.Equal(-1, result.Amount); }
public void WhenGeneratingChangeRequest_ShouldNotIncludeOperator() { var expected = "test"; var plugin = new KarmaPlugin(); var result = plugin.ParseKarmaChange("test++"); Assert.Equal(expected, result.Name); }
private IEnumerable <ResponseMessage> KarmaHandler(IncomingMessage message, IValidHandle matchedHandle) { var matches = _karmaPlugin.GetMessageMatches(message.FullText); foreach (Match match in matches) { var changeRequest = _karmaPlugin.ParseKarmaChange(match.Value); yield return(HandleKarmaChange(message, changeRequest)); } }
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)); } }