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

fix: use correct base path in Directory.CreateTempSubdirectory #1127

Merged
merged 3 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public override IDirectoryInfo CreateTempSubdirectory(string prefix = null)
// Perform directory name generation in a loop, just in case the randomly generated name already exists.
do
{
var randomDir = $"{prefix}{Path.GetRandomFileName()}";
potentialTempDirectory = Path.Combine(Path.GetTempPath(), randomDir);
var randomDir = $"{prefix}{FileSystem.Path.GetRandomFileName()}";
potentialTempDirectory = Path.Combine(FileSystem.Path.GetTempPath(), randomDir);
} while (Exists(potentialTempDirectory));

return CreateDirectoryInternal(potentialTempDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@

// Assert
Assert.That(fileSystem.Directory.Exists(result.FullName), Is.True);
Assert.That(result.FullName.Contains(Path.GetTempPath()), Is.True);
Assert.That(result.FullName, Does.StartWith(fileSystem.Path.GetTempPath()));
}

[Test]
Expand All @@ -877,7 +877,7 @@
// Assert
Assert.That(fileSystem.Directory.Exists(result.FullName), Is.True);
Assert.That(Path.GetFileName(result.FullName).StartsWith("foo-"), Is.True);
Assert.That(result.FullName.Contains(Path.GetTempPath()), Is.True);
Assert.That(result.FullName.Contains(fileSystem.Path.GetTempPath()), Is.True);
}
#endif

Expand Down Expand Up @@ -2069,7 +2069,7 @@
var fileSystem = new MockFileSystem();

// Act
Assert.Throws<DirectoryNotFoundException>(() => fileSystem.Directory.GetAccessControl(XFS.Path(@"c:\foo")));

Check warning on line 2072 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

This call site is reachable on all platforms. 'DirectoryAclExtensions.GetAccessControl(IDirectory, string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 2072 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

This call site is reachable on all platforms. 'DirectoryAclExtensions.GetAccessControl(IDirectory, string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 2072 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

This call site is reachable on all platforms. 'DirectoryAclExtensions.GetAccessControl(IDirectory, string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
}

[Test]
Expand Down
Loading