From 2c7f220a71a60eae546efeecb6ddb7f26445542f Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sun, 7 May 2023 10:26:35 -0500 Subject: [PATCH] refactor: Add LeafDirectories() extension method for MockFileSystem --- .../CommonMockFileSystemExtensions.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Recyclarr.Common.TestLibrary/CommonMockFileSystemExtensions.cs b/src/Recyclarr.Common.TestLibrary/CommonMockFileSystemExtensions.cs index e7a9870e..d8afc537 100644 --- a/src/Recyclarr.Common.TestLibrary/CommonMockFileSystemExtensions.cs +++ b/src/Recyclarr.Common.TestLibrary/CommonMockFileSystemExtensions.cs @@ -50,4 +50,9 @@ public static class CommonMockFileSystemExtensions var resourcePath = $"{typeInAssembly.Namespace}.{embeddedResourcePath}"; fs.AddFileFromEmbeddedResource(path, typeInAssembly.Assembly, resourcePath); } + + public static IEnumerable LeafDirectories(this MockFileSystem fs) + { + return fs.AllDirectories.Where(x => !fs.AllDirectories.Any(y => y.StartsWith(x) && y != x)); + } }