Skip to content

MockFileSystem does not support Root directories #702

@derecskey

Description

@derecskey

Describe the bug
Including a Root drive/directory in a MockFileSystem causes ArgumentNullException at line 82 of MockFileSystem.cs

To Reproduce
To recreate, execute the following line of code:

var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
    { @"c:\demo", new MockDirectoryData() },
    { @"z:\", new MockDirectoryData() },
    { @"Z:\foo", new MockDirectoryData() }
});

Expected behavior

"Z:" should be a valid directory.

Additional context

var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
    { @"c:\demo", new MockDirectoryData() },
    //{ @"z:\", new MockDirectoryData() },
    { @"Z:\foo", new MockDirectoryData() }
});  //This produces no exception

var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
    { @"c:\demo", new MockDirectoryData() },
    //{ @"z:\", new MockDirectoryData() },
    { @"Z:\foo", new MockDirectoryData() }
});  //This produces an exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testinghelpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked onstate: releasedIssues that are releasedtype: bugIssues that describe misbehaving functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions