public void MatchesTest(string pattern, string fileName, bool expectsMatch) { var wildcard = GlobMatcher.Create(pattern, new GlobMatcherOptions { IgnoreCase = true, AllowWindowsPaths = true }); var match = wildcard.IsMatch(fileName); Assert.AreEqual(expectsMatch, match, $"Failure with pattern {pattern}, fileName {fileName}, should match {expectsMatch}"); }
public void MatcherTest() { const string Glob = "C:/Projects/editorconfig-core-net/tests/filetree/top/of/path"; const string File = "C:/Projects/editorconfig-core-net/tests/filetree/top/of/path"; var m = GlobMatcher.Create(Glob, _globOptions); var match = m.IsMatch(File); match.Should().BeTrue(); }
private static void TestCase(string pattern, IList <string> expected, GlobMatcherOptions?options = null, IEnumerable <string>?input = null) { input ??= Files; var filtered = input; var mm = GlobMatcher.Create(pattern, options); filtered = filtered.Where(mm.IsMatch); if (options?.NoNull == true) { filtered = filtered.DefaultIfEmpty(pattern); } filtered = filtered.OrderBy(s => s); Assert.AreEqual( String.Join(Environment.NewLine, expected.OrderBy(s => s)), String.Join(Environment.NewLine, filtered), "Failure from `" + pattern + "`" ); }