Skip to content

MockFileSystem directory behavior with front slash inconsistent with actual file system behavior on Windows #1244

Closed

Description

@tbui17

Describe the bug
Both native Directory.Exists and the wrapper FileSystem.Directory.Exists methods successfully pick up the root directory using a /. However, MockFileSystem.Directory.Exists does not on Windows.

It's also worth noting that MockFileSystem.DirectoryInfo.Exists does work.

To Reproduce

[Test]
public async Task MockDirectory_Exists_ShouldReturnTrue_IfArgIsFrontSlashAndRootDirExists()
{
    string testDir = XFS.Path(@"c:\foo\bar\");
    var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
    {
        { testDir,  new MockDirectoryData() }
    });

    await That(fileSystem.Directory.Exists("/")).IsEqualTo(true);
}

Expected behavior
Test shouldn't fail on Windows.

Additional context
OS: Windows 11
.NET Version: net9.0/net8.0/net6.0/net472
Package Version: 22.0.11

Activity

  1. added
    type: bugIssues that describe misbehaving functionality
    on Mar 8, 2025
  2. tbui17 commented on Mar 8, 2025

    @tbui17
    ContributorAuthor

    Related PR: #294

  3. github-actions commented on Mar 13, 2025

    @github-actions

    This is addressed in release v22.0.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: 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