diff --git a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs
index 78910a1a9..1f1e3176a 100644
--- a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs
+++ b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDirectory.cs
@@ -602,7 +602,7 @@ public override void SetCreationTimeUtc(string path, DateTime creationTimeUtc)
///
public override void SetCurrentDirectory(string path)
{
- currentDirectory = path;
+ currentDirectory = mockFileDataAccessor.Path.GetFullPath(path);
}
///
diff --git a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs
index 0ecb83cdc..adfe56a9f 100644
--- a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs
+++ b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs
@@ -1661,6 +1661,17 @@ public void MockDirectory_SetCurrentDirectory_ShouldChangeCurrentDirectory()
Assert.AreEqual(directory, fileSystem.Directory.GetCurrentDirectory());
}
+ [Test]
+ public void MockDirectory_SetCurrentDirectory_WithRelativePath_ShouldUseFullPath()
+ {
+ var fileSystem = new MockFileSystem();
+ fileSystem.Directory.SetCurrentDirectory(".");
+
+ var result = fileSystem.Directory.GetCurrentDirectory();
+
+ Assert.IsTrue(fileSystem.Path.IsPathRooted(result));
+ }
+
[Test]
public void MockDirectory_GetParent_ShouldThrowArgumentNullExceptionIfPathIsNull()
{