Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple temp directories in MockFileSystem #1125

Closed
montoner0 opened this issue Jun 19, 2024 · 4 comments · Fixed by #1127
Closed

Multiple temp directories in MockFileSystem #1125

montoner0 opened this issue Jun 19, 2024 · 4 comments · Fixed by #1127
Labels
state: needs discussion Issues that need further discussion state: released Issues that are released type: bug Issues that describe misbehaving functionality

Comments

@montoner0
Copy link
Contributor

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.

@montoner0 montoner0 added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Jun 19, 2024
@vbreuss
Copy link
Member

vbreuss commented Jun 21, 2024

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);
        }

@montoner0
Copy link
Contributor Author

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

@vbreuss
Copy link
Member

vbreuss commented Jun 22, 2024

Sorry, @montoner0, my bad 🙈

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

Thanks for reporting!

Copy link

This is addressed in release v21.0.22.

@github-actions github-actions bot added the state: released Issues that are released label Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion Issues that need further discussion state: released Issues that are released type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants