Skip to content

Discrepancy between DirectoryInfo(Base).Exists in real file system and MockFileSystem DirectoryInfoBase.Exists #661

Closed

Description

@m-ringler

Describe the bug
System.IO.DirectoryInfo.Exists seems to store the "exists" information at the time of creation. MockFileSystem seems to use up-to-date information.

To Reproduce
Steps to reproduce the behavior:

        public void MockFileSystemDirectoryInfoExists_AfterCreate_ShouldBeFileSystemDirectoryInfoExists()
        {
            var folder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var di = new DirectoryInfo(folder);
            Debug.Assert(!di.Exists, "!di.Exists");
            di.Create();

            var mfs = new MockFileSystem();
            var di_mfs = mfs.DirectoryInfo.FromDirectoryName(folder);
            Debug.Assert(!di_mfs.Exists, "!di_mfs.Exists");
            di_mfs.Create();

            di_mfs.Exists.Should().Be(di.Exists);
        }

Expected behavior
Mock File System should behave like the real file system.

Additional context
.NET 4.6.2; System.IO.Abstractions 3.0.2

Activity

  1. issue-label-bot commented on Oct 27, 2020

    @issue-label-bot

    Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.93. Please mark this comment with 👍 or 👎 to give our bot feedback!

    Links: app homepage, dashboard and code for this bot.

  2. added
    state: ready to pickIssues that are ready for being worked on
    and removed on Oct 27, 2020
  3. fgreinacher commented on Oct 27, 2020

    @fgreinacher
    Contributor

    Interesting, thanks for reporting!

  4. added a commit that references this issue on Jan 8, 2022
    2b66b5d
  5. added
    state: in workIssues that are currently worked on
    and removed
    state: ready to pickIssues that are ready for being worked on
    on Jan 8, 2022
  6. added a commit that references this issue on Jan 9, 2022
    5216e0d
  7. github-actions commented on Jan 9, 2022

    @github-actions

    This is addressed in release v16.0.8.

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

    area: testinghelpersIssues that address the testing helpersstate: in workIssues that are currently 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