Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use searchPattern argument in GetFiles method to complete the logic #988

Merged
merged 4 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public override string[] GetFiles(string path, string searchPattern, SearchOptio
/// <inheritdoc />
public override string[] GetFiles(string path, string searchPattern, EnumerationOptions enumerationOptions)
{
return GetFiles(path, "*", EnumerationOptionsToSearchOption(enumerationOptions));
return GetFiles(path, searchPattern, EnumerationOptionsToSearchOption(enumerationOptions));
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@ public void MockDirectory_GetFiles_ShouldReturnAllFilesBelowPathWhenPatternIsWil
Assert.That(result, Is.EquivalentTo(expected));
}

#if FEATURE_ENUMERATION_OPTIONS
[Test]
public void MockDirectory_GetFiles_ShouldReturnAllPatternMatchingFilesWhenEnumerationOptionHasRecurseSubdirectoriesSetToTrue()
{
// Arrange
var fileSystem = SetupFileSystem();
var expected = new[]
{
XFS.Path(@"c:\b.txt"),
XFS.Path(@"c:\c.txt"),
XFS.Path(@"c:\a\a.txt"),
XFS.Path(@"c:\a\c.txt"),
XFS.Path(@"c:\a\a\a.txt"),
XFS.Path(@"c:\a\a\b.txt")
};

// Act
var result = fileSystem.Directory.GetFiles(XFS.Path(@"c:\"), "*.txt", new EnumerationOptions { RecurseSubdirectories = true });

// Assert
Assert.That(result, Is.EquivalentTo(expected));
}
#endif

private MockFileSystem SetupFileSystem()
{
return new MockFileSystem(new Dictionary<string, MockFileData>
Expand Down