From 185f7fd6638a650673fe38141c731f26d60cb95a Mon Sep 17 00:00:00 2001 From: Thomas Bittner Date: Fri, 20 Oct 2023 16:00:15 +0200 Subject: [PATCH] Add a test that demonstrates the prefix logic of `MockDirectory.EnumerateDirectories` --- .../MockDirectoryTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs index acb5a1777..ccf46e5fe 100644 --- a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs +++ b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs @@ -1486,6 +1486,22 @@ public void MockDirectory_EnumerateDirectories_ShouldThrowWhenPathIsNotMocked() // Assert Assert.Throws(action); } + + + [TestCase("Folder", "Folder/SubFolder")] + [TestCase("/Folder", "/Folder/SubFolder")] + [TestCase("Folder/", "Folder/SubFolder")] + [TestCase("Folder/.././Folder", "Folder/.././Folder/SubFolder")] + public void MockDirectory_EnumerateDirectories_ShouldReturnPathsPrefixedWithQueryPath( + string queryPath, string expectedPath) + { + var fileSystem = new MockFileSystem(); + fileSystem.Directory.CreateDirectory("Folder/SubFolder"); + + var actualResult = fileSystem.Directory.EnumerateDirectories(queryPath); + + CollectionAssert.AreEqual(new[] { expectedPath }, actualResult); + } public static IEnumerable GetPathsForMoving() {