From cde5f4ff819e38b7198f41ec53db6086026174b3 Mon Sep 17 00:00:00 2001 From: Thomas Bittner Date: Wed, 15 Nov 2023 18:20:42 +0100 Subject: [PATCH] Make prefix tests run on both Windows an Unix --- .../MockDirectoryTests.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs index 1bdc1d775..289b8dc90 100644 --- a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs +++ b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs @@ -1487,10 +1487,7 @@ public void MockDirectory_EnumerateDirectories_ShouldThrowWhenPathIsNotMocked() Assert.Throws(action); } - - [TestCase("Folder", @"Folder\SubFolder")] - [TestCase(@"Folder\", @"Folder\SubFolder")] - [TestCase(@"Folder\..\.\Folder", @"Folder\..\.\Folder\SubFolder")] + [TestCaseSource(nameof(GetPrefixTestPaths))] public void MockDirectory_EnumerateDirectories_ShouldReturnPathsPrefixedWithQueryPath( string queryPath, string expectedPath) { @@ -1501,6 +1498,14 @@ public void MockDirectory_EnumerateDirectories_ShouldReturnPathsPrefixedWithQuer CollectionAssert.AreEqual(new[] { expectedPath }, actualResult); } + + private static IEnumerable GetPrefixTestPaths() + { + var sep = Path.DirectorySeparatorChar; + yield return new object[] { "Folder", $"Folder{sep}SubFolder" }; + yield return new object[] { $"Folder{sep}", $"Folder{sep}SubFolder" }; + yield return new object[] { $"Folder{sep}..{sep}.{sep}Folder", $"Folder{sep}..{sep}.{sep}Folder{sep}SubFolder" }; + } public static IEnumerable GetPathsForMoving() {