Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -10,6 +10,24 @@ public abstract partial class GetFilesTests<TFileSystem>
: FileSystemTestBase<TFileSystem>
where TFileSystem : IFileSystem
{
[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}");
var result = FileSystem.Directory.GetFiles($@"..\{subfolder1}\{subfolder2}").ToList();

IEnumerable<string> expectation = files.Select(f => System.IO.Path.Combine("..", subfolder1, subfolder2, f));
result.Should().BeEquivalentTo(expectation);
}

[SkippableTheory]
[AutoData]
public void
Expand Down