public void ShouldReturnExistingFiles(string directory, string[] patterns, string[] expected, bool reverseSlashes) { // TestContext.Out.WriteLine($"Patterns: {string.Join(",", patterns)}"); // Given TestFileProvider fileProvider = GetFileProvider(); fileProvider.AddDirectory("/"); fileProvider.AddDirectory("/q"); fileProvider.AddFile("/q/werty.txt"); IFileSystem fileSystem = new TestFileSystem(fileProvider); IDirectory dir = fileSystem.GetDirectory(directory); // When IEnumerable <IFile> results = fileSystem.GetFiles(dir, patterns); // Then CollectionAssert.AreEquivalent(expected, results.Select(x => x.Path.FullPath)); if (reverseSlashes) { // When results = fileSystem.GetFiles(dir, patterns.Select(x => x.Replace("/", "\\"))); // Then CollectionAssert.AreEquivalent(expected, results.Select(x => x.Path.FullPath)); } }
public void ShouldThrowForNullPatterns() { // Given IFileSystem fileSystem = new TestFileSystem(GetFileProvider()); IDirectory dir = fileSystem.GetDirectory("/"); // When, Then Should.Throw <ArgumentNullException>(() => fileSystem.GetFiles(dir, null)); }
public void ShouldNotThrowForNullPattern() { // Given IFileSystem fileSystem = new TestFileSystem(GetFileProvider()); IDirectory dir = fileSystem.GetDirectory("/"); // When IEnumerable <IFile> results = fileSystem.GetFiles(dir, null, "**/foo.txt"); // Then CollectionAssert.AreEquivalent(new[] { "/a/b/c/foo.txt" }, results.Select(x => x.Path.FullPath)); }