public void GlobUtilCanMatchSingle() { var glob = new SolutionGen.Utils.CompositeGlob(new[] { "*.cs" }, new[] { "*.txt" }); Assert.True(glob.IsMatch("/Path/To/File.cs")); Assert.False(glob.IsMatch("/Path/To/File.txt")); }
public void GlobDirectoryInfoReturnsRelativePaths() { var dir = new DirectoryInfo(Directory.GetCurrentDirectory()); string[] results = new SolutionGen.Utils.CompositeGlob(new[] { "*" }, new string[0]).FilterMatches(dir).ToArray(); Assert.Contains(results, s => s[0] != '/' && s[0] != '\\'); Assert.True(results.All(r => new FileInfo(Path.Combine(dir.FullName, r)).Exists)); }
public void GlobUtilCanMatchMultiple() { var glob = new SolutionGen.Utils.CompositeGlob(new[] { "*.cs" }, new[] { "*.txt", "**/ExcludedDir/**" }); string[] matches = glob.FilterMatches(new[] { "/Path/To/File1.cs", "/Path/To/File2.cs", "/Path/To/File1.txt", "/Path/To/File2.txt", "/Path/To/ExcludedDir/File.cs", }).ToArray(); Assert.Equal(new[] { "/Path/To/File1.cs", "/Path/To/File2.cs" }, matches); }