I hope the following code is self explaining:
[Fact]
public void RelativePathBugTest()
{
// arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>());
const string dir = @"C:\test";
fileSystem.Directory.SetCurrentDirectory(dir);
fileSystem.AddFile($@"C:\test.txt", new MockFileData("Some ASCII text."));
fileSystem.File.Exists(@"C:\test.txt").Should().BeTrue();
fileSystem.File.Exists(@"..\test.txt").Should().BeTrue(); // relative path works fine
fileSystem.Directory.GetFiles(@"C:\").Length.Should().Be(1);
fileSystem.Directory.GetFiles(@"..\").Length.Should().Be(1); // this line fails.
}
I hope the following code is self explaining: