diff --git a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs index d7f0a6d34..b5376487d 100644 --- a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs +++ b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs @@ -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); diff --git a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs index 343a98f26..fbd0fc41f 100644 --- a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs +++ b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs @@ -862,7 +862,7 @@ public void MockDirectory_CreateTempSubdirectory_ShouldCreateSubdirectoryInTempD // 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] @@ -877,7 +877,7 @@ public void MockDirectory_CreateTempSubdirectoryWithPrefix_ShouldCreateDirectory // 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