Skip to content

Commit 87630ba

Browse files
committed
Test that MockDirectory.CreateDirectory supports windows extended-length paths
Windows paths can have a `\\?\` prefix, the '?' character is not always invalid. Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry Refers to #1304
1 parent 89966df commit 87630ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,20 @@ public async Task MockDirectory_CreateDirectory_ShouldThrowIfIllegalCharacterInP
747747
await That(createDelegate).Throws<ArgumentException>();
748748
}
749749

750+
[Test]
751+
[WindowsOnly(WindowsSpecifics.UNCPaths)]
752+
public async Task MockDirectory_CreateDirectory_ShouldSupportExtendedLengthPaths()
753+
{
754+
// Arrange
755+
var fileSystem = new MockFileSystem();
756+
757+
// Act
758+
fileSystem.Directory.CreateDirectory(XFS.Path(@"\\?\c:\bar"));
759+
760+
// Assert
761+
await That(fileSystem.Directory.Exists(XFS.Path(@"\\?\c:\bar"))).IsTrue();
762+
}
763+
750764
// Issue #210
751765
[Test]
752766
public async Task MockDirectory_CreateDirectory_ShouldIgnoreExistingDirectoryRegardlessOfTrailingSlash()
@@ -2219,4 +2233,4 @@ public static void MockDirectory_Move_ShouldNotThrowException_InWindows_When_Sou
22192233
// Act & Assert
22202234
Assert.DoesNotThrow(() => mockFs.Directory.Move(src, dest));
22212235
}
2222-
}
2236+
}

0 commit comments

Comments
 (0)