From b5659308fb3a00d73e511bbfff5fc3d2e67f60bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 11 Jul 2026 11:04:13 +0200 Subject: [PATCH] test: skip extended-length and invalid path tests on .NET Framework On .NET Framework 'Path.GetFullPath' rejects '\?\' device paths and throws a culture-dependent exception for invalid paths, so these tests fail unreliably (they turn red once tests are forced to run under the invariant culture). Skip them on .NET Framework; they continue to run and pass on modern targets. --- .../FileSystem/Directory/CreateDirectoryTests.cs | 1 + .../Directory/EnumerateDirectoriesTests.cs | 2 ++ .../FileSystem/File/CopyTests.cs | 16 +++++----------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs index a65001ab6..b892cb1df 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs @@ -54,6 +54,7 @@ await That(FileSystem.DirectoryInfo.New(parent).Attributes) public async Task CreateDirectory_ShouldSupportExtendedLengthPaths() { Skip.If(!Test.RunsOnWindows); + Skip.If(Test.IsNetFramework, "Extended-length paths are not supported on .NET Framework."); FileSystem.DirectoryInfo.New(@"\\?\c:\bar").Create(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs index 6570abf14..a2da64803 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs @@ -215,6 +215,7 @@ public async Task EnumerateDirectories_ShouldIncludeEmptyDirectoriesWithTrailing public async Task EnumerateDirectories_ShouldSupportExtendedLengthPaths1() { Skip.If(!Test.RunsOnWindows); + Skip.If(Test.IsNetFramework, "Extended-length paths are not supported on .NET Framework."); FileSystem.Directory.CreateDirectory(@"\\?\c:\bar"); FileSystem.File.WriteAllText(@"\\?\c:\bar\foo1.txt", "foo1"); @@ -231,6 +232,7 @@ await That(result) public async Task EnumerateDirectories_ShouldSupportExtendedLengthPaths2() { Skip.If(!Test.RunsOnWindows); + Skip.If(Test.IsNetFramework, "Extended-length paths are not supported on .NET Framework."); FileSystem.Directory.CreateDirectory(@"\\?\c:\bar"); FileSystem.File.WriteAllText(@"\\?\c:\bar\foo1.txt", "foo1"); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs index 092522e2d..cbd706224 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs @@ -116,23 +116,17 @@ public async Task string source, string destination) { Skip.IfNot(Test.RunsOnWindows); + Skip.If(Test.IsNetFramework, "Invalid paths throw inconsistently on .NET Framework."); void Act() { FileSystem.File.Copy(source, destination); } - if (Test.IsNetFramework) - { - await That(Act).Throws().WithHResult(-2146233067); - } - else - { - await That(Act).Throws() - .WithMessageContaining( - "The filename, directory name, or volume label syntax is incorrect").And - .WithHResult(-2147024773); - } + await That(Act).Throws() + .WithMessageContaining( + "The filename, directory name, or volume label syntax is incorrect").And + .WithHResult(-2147024773); } [Test]