public void IsMatchWithCaseSensitiveReturnsFalseForEquivalentMatch() { // Arrange. const string Path = "/WebApp/Administration/Test.aspx?Param1=42&Param2=No"; const string Pattern = "/webapp/administration/test.aspx?param1=42¶m2=no"; var matcher = new ExactPathMatcher(); // Act. var result = matcher.IsMatch(Path, Pattern, false); // Assert. Assert.False(result); }
public void IsMatchReturnsFalseForMissingQuery() { // Arrange. const string Path = "/WebApp/Administration/Test.aspx?Param1=42&Param2=No"; const string Pattern = "/WebApp/Administration/Test.aspx"; var matcher = new ExactPathMatcher(); // Act. var result = matcher.IsMatch(Path, Pattern, true); // Assert. Assert.False(result); }
/// <summary> /// Creates an appropriate path matcher for the specified match type. /// </summary> /// <param name="matchType">The PathMatchType used to determine the appropriate path matcher.</param> /// <returns></returns> public static IPathMatcher Create(PathMatchType matchType) { // Check for cached matchers first. IDictionary <PathMatchType, IPathMatcher> cachedMatchers = CachedMatchers; if (cachedMatchers != null && cachedMatchers.ContainsKey(matchType)) { IPathMatcher cachedPathMatcher = cachedMatchers[matchType]; Logger.LogFormat("Cached {0} retrieved.", cachedPathMatcher.GetType().Name); return(cachedPathMatcher); } // Create the appropriate path matcher. IPathMatcher pathMatcher; switch (matchType) { case PathMatchType.Regex: pathMatcher = new RegexPathMatcher(); break; case PathMatchType.StartsWith: pathMatcher = new StartsWithPathMatcher(); break; case PathMatchType.Exact: pathMatcher = new ExactPathMatcher(); break; default: throw new ArgumentOutOfRangeException("matchType"); } // Cache the path matcher, if possible. if (cachedMatchers != null) { cachedMatchers.Add(matchType, pathMatcher); } Logger.LogFormat("Creating {0}.", pathMatcher.GetType().Name); return(pathMatcher); }
/// <summary> /// Creates an appropriate path matcher for the specified match type. /// </summary> /// <param name="matchType">The PathMatchType used to determine the appropriate path matcher.</param> /// <returns></returns> public static IPathMatcher Create(PathMatchType matchType) { // Check for cached matchers first. IDictionary<PathMatchType, IPathMatcher> cachedMatchers = CachedMatchers; if (cachedMatchers != null && cachedMatchers.ContainsKey(matchType)) { IPathMatcher cachedPathMatcher = cachedMatchers[matchType]; Logger.LogFormat("Cached {0} retrieved.", cachedPathMatcher.GetType().Name); return cachedPathMatcher; } // Create the appropriate path matcher. IPathMatcher pathMatcher; switch (matchType) { case PathMatchType.Regex: pathMatcher = new RegexPathMatcher(); break; case PathMatchType.StartsWith: pathMatcher = new StartsWithPathMatcher(); break; case PathMatchType.Exact: pathMatcher = new ExactPathMatcher(); break; default: throw new ArgumentOutOfRangeException("matchType"); } // Cache the path matcher, if possible. if (cachedMatchers != null) { cachedMatchers.Add(matchType, pathMatcher); } Logger.LogFormat("Creating {0}.", pathMatcher.GetType().Name); return pathMatcher; }