public void TestGivenRegexPatternToStringDictionaryWithEscapedPatternWhenCheckingForMatchesThenCorrectResultReturned() { IRegexPatternDictionary <string> regexDict = new RegexPatternDictionaryImpl <string>(); regexDict.AddEscapedFullMatchPattern("hello", "this"); regexDict.AddEscapedFullMatchPattern("wo+rld", "is"); regexDict.AddEscapedFullMatchPattern("a.*y", "good"); regexDict.AddEscapedFullMatchPattern("b.*", "bad"); Assert.True(regexDict.HasMatch("hello"), "Expected 'hello' to have a match in the dictionary"); Assert.True(regexDict.HasMatch("a.*y"), "Expected 'a.*y' to have a match in the dictionary"); Assert.False(regexDict.HasMatch("hi"), "Expected 'hi' to not have a match in the dictionary"); Assert.False(regexDict.HasMatch("week"), "Expected 'week' to not have a match in the dictionary"); Assert.False(regexDict.HasMatch("john"), "Expected 'john' to not have a match in the dictionary"); Assert.False(regexDict.HasMatch("doe"), "Expected 'doe' to not have a match in the dictionary"); }
public void TestGivenRegexPatternToStringDictionaryWithEscapedPatternWhenGetValueByPatternThenCorrectValueReturned() { IRegexPatternDictionary <string> regexDict = new RegexPatternDictionaryImpl <string>(); string pattern = "hel+o"; string value = "world"; regexDict.AddEscapedFullMatchPattern(pattern, value); Assert.True(regexDict.ContainsKey(pattern), "Pattern should exist as dictionary key"); Assert.AreEqual(value, regexDict[pattern], "Value tied to pattern should be correct"); }