MockFileSystem with currentDirectory should return only one currentDirectory
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ @"myfile.txt", new MockFileData("A") },
}, @"current");
makes
fileSystem.AllFiles.Single()
return
"current\current\current\myfile.txt"
which is two too many.
I also believe there should be a prepending \.
A remedy is to prepend "current" with a slash like so"
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ @"myfile.txt", new MockFileData("A") },
}, @"\current");
to give the result
"\current\myfile.txt"
Although I present a work around it might be considered a but as it is imho an unexpected behaviour.
Thanks for reporting! I’m wondering whether we should force currentDirectory to be an absolute path.
Forcing currentDirectory to be rooted sounds ok to me.
FWIW: Retrieving Environment.CurrentDirectory alway returns a rooted path. (with drive letter in Windows and /mnt in WSL. (I have not tried WSL2))
Setting it does not have to be rooted but can be relative to current directory.