Skip to content
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 @@ -45,7 +45,7 @@ internal static string GetSubdirectoryPath(this IFileSystem fileSystem,
return fullFilePath;
}

string currentDirectory = fileSystem.Directory.GetCurrentDirectory();
string currentDirectory = fileSystem.Path.GetFullPath(givenPath);
if (currentDirectory == string.Empty.PrefixRoot())
{
fullFilePath = fullFilePath.Substring(currentDirectory.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ public void
result.Should().NotContain(initialized[3].ToString());
}

[SkippableTheory]
[AutoData]
public void GetFiles_WithRelativePathAndSubfolders_ShouldReturnRelativeFilePath(
string subfolder1, string subfolder2, string[] files)
{
string workingDirectory = System.IO.Path.Combine(BasePath, subfolder1, subfolder2);
FileSystem.Directory.CreateDirectory(workingDirectory);
foreach (string file in files)
{
FileSystem.File.Create(System.IO.Path.Combine(workingDirectory, file));
}
FileSystem.Directory.SetCurrentDirectory(subfolder1);
IEnumerable<string> expectation =
files.Select(f => System.IO.Path.Combine("..", subfolder1, subfolder2, f));
var path = System.IO.Path.Combine("..", subfolder1, subfolder2);

List<string> result = FileSystem.Directory.GetFiles(path).ToList();

result.Should().BeEquivalentTo(expectation);
}

[SkippableTheory]
[AutoData]
public void GetFiles_WithSearchPattern_ShouldReturnMatchingFiles(
Expand Down