Skip to content

Multiple temp directories in MockFileSystem #1125

Description

@montoner0

Describe the bug
The default temp directory, which is created automatically, is not the same as used by the MockDirectory.CreateTempSubdirectory() method.

To Reproduce
Steps to reproduce the behavior:

var fileSystem = new MockFileSystem();
var result = fileSystem.Directory.CreateTempSubdirectory();
var temp = fileSystem.Path.GetTempPath();
result.FullName.StartsWith(temp); // expected true but false

Expected behavior
It's expected that there's a single temp directory in the mocked file system but MockDirectory.CreateTempSubdirectory() uses the current user's temp path instead.

Additional context
Also there's no way to specify the temp directory manually.

Activity

  1. vbreuss commented on Jun 21, 2024

    @vbreuss
    Member

    Thanks for reporting, @montoner0, but I couldn't reproduce this issue. I executed the following test and it was successful:

            [Test]
            public void MockDirectory_CreateTempSubdirectory_ShouldStartWithTempPath()
            {
                var fileSystem = new MockFileSystem();
                var result = fileSystem.Directory.CreateTempSubdirectory();
                var temp = fileSystem.Path.GetTempPath();
                result.FullName.StartsWith(temp);
            }
  2. montoner0 commented on Jun 21, 2024

    @montoner0
    ContributorAuthor

    @vbreuss
    I believe you have to assert the result of the last line to fail the test.
    Assert.That(result.FullName.StartsWith(temp));

  3. added a commit that references this issue on Jun 22, 2024
  4. vbreuss commented on Jun 22, 2024

    @vbreuss
    Member

    Sorry, @montoner0, my bad 🙈

    I created a pull request, that should fix your issue and will be published shortly.

    Thanks for reporting!

  5. github-actions commented on Jun 22, 2024

    @github-actions

    This is addressed in release v21.0.22.

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: needs discussionIssues that need further discussionstate: 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