public void Matches_GivenTextWithNoMatches_ReturnsEmptyList(MatcherFactory.MatchAlgorithm algorithm, List <string> patterns, String testString) { var matcher = factory.Create(patterns, algorithm); Assert.IsEmpty(matcher.Matches(new StringReader(testString))); }
public void IsMatch_GivenTextWithNoMatches_ReturnsFalse(MatcherFactory.MatchAlgorithm algorithm, List <string> patterns, String testString) { var matcher = factory.Create(patterns, algorithm); Assert.IsFalse(matcher.IsMatch(new StringReader(testString))); }
public void Matches_GivenTextWithMatches_ReturnsListWithMatches(MatcherFactory.MatchAlgorithm algorithm, List <string> patterns, String testString, List <Match> expectedMatches) { var matcher = factory.Create(patterns, algorithm); Assert.IsTrue(Enumerable.SequenceEqual(matcher.Matches(new StringReader(testString)), expectedMatches)); }
public void Match_GivenTextWithMatches_ReturnsMatch(MatcherFactory.MatchAlgorithm algorithm, List <string> patterns, String testString, Match expectedMatch) { var matcher = factory.Create(patterns, algorithm); Assert.AreEqual(matcher.Match(new StringReader(testString)), expectedMatch); }
public void IsMatch_GivenMultipleLinesString_AndTextWithAMatch_ReturnsTrue(MatcherFactory.MatchAlgorithm algorithm) { var matcher = factory.Create(new List <string> { "p1" }, algorithm); var text = "12\r\np13456\r\n7p189p10"; Assert.IsTrue(matcher.IsMatch(new StringReader(text))); }
public void IsMatch_GivenMultipleLinesStream_AndTextWithAMatch_ReturnsTrue(MatcherFactory.MatchAlgorithm algorithm) { var matcher = factory.Create(new List <string> { "p1" }, algorithm); using (var stream = new MemoryStream()) { var writer = new StreamWriter(stream); writer.WriteLine("12"); writer.WriteLine("p13456"); writer.WriteLine("7p189p10"); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); Assert.IsTrue(matcher.IsMatch(new StreamReader(stream))); } }
public void Matches_GivenMultipleLinesSring_AndTextWithAMatch_ReturnsListWithTheMatch_CountingTheNewline(MatcherFactory.MatchAlgorithm algorithm) { var matcher = factory.Create(new List <string> { "p1" }, algorithm); var text = "12\r\np13456\r\n7p189p10"; var expectedMatches = new List <Match> { new Match(4, "p1"), new Match(13, "p1"), new Match(17, "p1") }; Assert.IsTrue(Enumerable.SequenceEqual(matcher.Matches(new StringReader(text)), expectedMatches)); }
public void Match_GivenMultipleLinesString_AndTextWithAMatch_ReturnsTheMatch_CountingTheNewline(MatcherFactory.MatchAlgorithm algorithm) { var matcher = factory.Create(new List <string> { "p1" }, algorithm); var text = "12\r\np13456\r\n7p189p10"; Assert.AreEqual(matcher.Match(new StringReader(text)), new Match(4, "p1")); }
public void Matches_GivenMultipleLinesStream_AndTextWithAMatch_ReturnsListWithTheMatch_CountingTheNewline(MatcherFactory.MatchAlgorithm algorithm) { var matcher = factory.Create(new List <string> { "p1" }, algorithm); using (var stream = new MemoryStream()) { var writer = new StreamWriter(stream); writer.WriteLine("12"); writer.WriteLine("p13456"); writer.WriteLine("7p189p10"); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); var expectedMatches = new List <Match> { new Match(4, "p1"), new Match(13, "p1"), new Match(17, "p1") }; Assert.IsTrue(Enumerable.SequenceEqual(matcher.Matches(new StreamReader(stream)), expectedMatches)); } }