From def934ebeb3178fc77cac1676f702d93f19efae9 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sat, 5 Aug 2023 22:23:09 -0500 Subject: [PATCH] refactor: Upgrade FileSystem to remove hack This version of `System.IO.Abstractions` adds constructor options to `MockFileSystem` that allows the removal of a hack put in place to remove the temp directory so it does not interfere with unit test expectations. --- src/Directory.Packages.props | 6 +++--- .../TrashLibIntegrationFixture.cs | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index e5e7b92b..353a14e7 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -32,9 +32,9 @@ - + - + @@ -58,7 +58,7 @@ - + diff --git a/src/tests/Recyclarr.TrashLib.TestLibrary/TrashLibIntegrationFixture.cs b/src/tests/Recyclarr.TrashLib.TestLibrary/TrashLibIntegrationFixture.cs index 352929ac..ace193a2 100644 --- a/src/tests/Recyclarr.TrashLib.TestLibrary/TrashLibIntegrationFixture.cs +++ b/src/tests/Recyclarr.TrashLib.TestLibrary/TrashLibIntegrationFixture.cs @@ -18,9 +18,10 @@ public abstract class TrashLibIntegrationFixture : IDisposable { protected TrashLibIntegrationFixture() { - // todo: Remove later. Needed because of this issue: - // https://github.com/TestableIO/System.IO.Abstractions/issues/983 - Fs.Directory.Delete("temp", true); + Fs = new MockFileSystem(new MockFileSystemOptions + { + CreateDefaultTempDir = false + }); Paths = new AppPaths(Fs.CurrentDirectory().SubDirectory("test").SubDirectory("recyclarr")); Logger = CreateLogger(); @@ -76,7 +77,7 @@ public abstract class TrashLibIntegrationFixture : IDisposable private readonly Lazy _container; protected ILifetimeScope Container => _container.Value; - protected MockFileSystem Fs { get; } = new(); + protected MockFileSystem Fs { get; } protected TestConsole Console { get; } = new(); protected IAppPaths Paths { get; } protected ILogger Logger { get; }