public void ShouldNotMatchInvalidInputs(string input) { int expected = 0; var plugin = new KarmaPlugin(); var matches = plugin.GetMessageMatches(input); int numberOfMatches = matches.Count; Assert.Equal(expected, numberOfMatches); }
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)); } }
public void ShouldMatchValidInputs(string input) { int expected = 1; var plugin = new KarmaPlugin(); var matches = plugin.GetMessageMatches(input); int numberOfMatches = matches.Count; Assert.Equal(expected, numberOfMatches); output.WriteLine($"Matched {matches[0].Value}"); }
public void GivenWhitespace_ShouldOnlyMatchCharacters() { int expectedCount = 1; var expectedMatchvalue = "test++"; var plugin = new KarmaPlugin(); var matches = plugin.GetMessageMatches(" test++ "); int numberOfMatches = matches.Count; Assert.Equal(expectedCount, numberOfMatches); Assert.Equal(expectedMatchvalue, matches[0].Value); }
public void GivenHyphenatedPhrase_ShouldTreatNormally() { int expectedCount = 2; var expectedMatchvalueOne = "hyphenated-word--"; var expectedMatchvalueTwo = "part-time-teachers++"; var plugin = new KarmaPlugin(); var matches = plugin.GetMessageMatches("hyphenated-word-- part-time-teachers++"); int numberOfMatches = matches.Count; Assert.Equal(expectedCount, numberOfMatches); Assert.Equal(expectedMatchvalueOne, matches[0].Value); Assert.Equal(expectedMatchvalueTwo, matches[1].Value); }
public void GivenAdditionalPlusesOrMinnuses_ShouldMatchOnlyTwo() { int expectedCount = 4; var expectedMatchvalueOne = "test++"; var expectedMatchvalueTwo = "test--"; var plugin = new KarmaPlugin(); var matches = plugin.GetMessageMatches("test+++ test++++++++++ test--- test----------"); int numberOfMatches = matches.Count; Assert.Equal(expectedCount, numberOfMatches); Assert.Equal(expectedMatchvalueOne, matches[0].Value); Assert.Equal(expectedMatchvalueOne, matches[1].Value); Assert.Equal(expectedMatchvalueTwo, matches[2].Value); Assert.Equal(expectedMatchvalueTwo, matches[3].Value); }