public void WhenGeneratingChangeRequest_ShouldNotIncludeOperator() { string expected = "test"; var plugin = new KarmaPlugin(); var result = plugin.ParseKarmaChangeWithReason("test++ for test"); Assert.Equal(expected, result.Name); }
public void WhenUsingNegativeKarmaOperator_ShouldHaveChangeAmoutNegativeOne() { var plugin = new KarmaPlugin(); var result = plugin.ParseKarmaChangeWithReason("test-- for test"); Assert.Equal(-1, result.Amount); }
public void ShouldFillReasonField() { string expected = "for test"; var plugin = new KarmaPlugin(); var result = plugin.ParseKarmaChangeWithReason("test-- for test"); Assert.Equal(expected, result.Reason); }
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)); } }