-
-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
Description
On Net framework create a default "MockFileSystem" seems to default create a C drive but no root directory. So if the unit test creates files on other drives then C. Then fs.DriveInfo.GetDrives().SelectMany(drive => drive.RootDirectory.EnumerateFiles("*", SearchOption.AllDirectories)).ToList()
throws error ->
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:'
Here some sample code
[TestMethod]
public void Test()
{
var fs = new MockFileSystem();
//fs.Directory.CreateDirectory(fs.Directory.GetCurrentDirectory()); // If force creating folder it works
var files = fs.DriveInfo.GetDrives()
.SelectMany(drive => drive.RootDirectory.EnumerateFiles("*", SearchOption.AllDirectories)).ToList();
Console.WriteLine(files.Count);
}
Is this really correct behavior? fells like root folder should exist for the drive?