diff --git a/Directory.Packages.props b/Directory.Packages.props index 3063fe0f7..e810d9d03 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,10 +5,11 @@ - - + + + diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs index b914e6e1b..068f22f8e 100644 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs +++ b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs @@ -19,6 +19,7 @@ protected override void GenerateSource(StringBuilder sourceBuilder, ClassModel @ using Testably.Abstractions.Testing.Initializer; using Testably.Abstractions.TestHelpers; using Testably.Abstractions.TestHelpers.Settings; +using System.IO.Abstractions.TestingHelpers; using Xunit.Abstractions; namespace {@class.Namespace} @@ -35,18 +36,18 @@ public abstract partial class {@class.Name} namespace {@class.Namespace}.{@class.Name} {{ // ReSharper disable once UnusedMember.Global - public sealed class MockFileSystemTests : {@class.Name}, IDisposable + public sealed class MockFileSystemTests : {@class.Name}, IDisposable {{ /// public override string BasePath => _directoryCleaner.BasePath; private readonly IDirectoryCleaner _directoryCleaner; - public MockFileSystemTests() : this(new MockFileSystem()) + public MockFileSystemTests() : this(new Testably.Abstractions.Testing.MockFileSystem()) {{ }} - private MockFileSystemTests(MockFileSystem mockFileSystem) : base( + private MockFileSystemTests(Testably.Abstractions.Testing.MockFileSystem mockFileSystem) : base( new Test(), mockFileSystem, mockFileSystem.TimeSystem) @@ -73,6 +74,47 @@ public override void SkipIfLongRunningTestsShouldBeSkipped() }} }} +namespace {@class.Namespace}.{@class.Name} +{{ + // ReSharper disable once UnusedMember.Global + public sealed class TestableIoMockFileSystemTests : {@class.Name}, IDisposable + {{ + /// + public override string BasePath => _directoryCleaner.BasePath; + + private readonly IDirectoryCleaner _directoryCleaner; + + public TestableIoMockFileSystemTests() : this(new System.IO.Abstractions.TestingHelpers.MockFileSystem()) + {{ + }} + + private TestableIoMockFileSystemTests(System.IO.Abstractions.TestingHelpers.MockFileSystem mockFileSystem) : base( + new Test(), + mockFileSystem, + new RealTimeSystem()) + {{ + _directoryCleaner = FileSystem + .SetCurrentDirectoryToEmptyTemporaryDirectory(); + }} + + /// + public void Dispose() + => _directoryCleaner.Dispose(); + + /// + public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) + {{ + // Brittle tests are never skipped against the mock file system! + }} + + /// + public override void SkipIfLongRunningTestsShouldBeSkipped() + {{ + // Long-running tests are never skipped against the mock file system! + }} + }} +}} + namespace {@class.Namespace}.{@class.Name} {{ // ReSharper disable once UnusedMember.Global @@ -140,19 +182,19 @@ public override void SkipIfLongRunningTestsShouldBeSkipped() namespace {@class.Namespace}.{@class.Name} {{ // ReSharper disable once UnusedMember.Global - public sealed class LinuxFileSystemTests : {@class.Name}, IDisposable + public sealed class LinuxFileSystemTests : {@class.Name}, IDisposable {{ /// public override string BasePath => _directoryCleaner.BasePath; private readonly IDirectoryCleaner _directoryCleaner; - public LinuxFileSystemTests() : this(new MockFileSystem(o => + public LinuxFileSystemTests() : this(new Testably.Abstractions.Testing.MockFileSystem(o => o.SimulatingOperatingSystem(SimulationMode.Linux))) {{ }} - private LinuxFileSystemTests(MockFileSystem mockFileSystem) : base( + private LinuxFileSystemTests(Testably.Abstractions.Testing.MockFileSystem mockFileSystem) : base( new Test(OSPlatform.Linux), mockFileSystem, mockFileSystem.TimeSystem) @@ -180,18 +222,18 @@ public override void SkipIfLongRunningTestsShouldBeSkipped() #if !NETFRAMEWORK // ReSharper disable once UnusedMember.Global - public sealed class MacFileSystemTests : {@class.Name}, IDisposable + public sealed class MacFileSystemTests : {@class.Name}, IDisposable {{ /// public override string BasePath => _directoryCleaner.BasePath; private readonly IDirectoryCleaner _directoryCleaner; - public MacFileSystemTests() : this(new MockFileSystem(o => + public MacFileSystemTests() : this(new Testably.Abstractions.Testing.MockFileSystem(o => o.SimulatingOperatingSystem(SimulationMode.MacOS))) {{ }} - private MacFileSystemTests(MockFileSystem mockFileSystem) : base( + private MacFileSystemTests(Testably.Abstractions.Testing.MockFileSystem mockFileSystem) : base( new Test(OSPlatform.OSX), mockFileSystem, mockFileSystem.TimeSystem) @@ -219,18 +261,18 @@ public override void SkipIfLongRunningTestsShouldBeSkipped() #if !NETFRAMEWORK // ReSharper disable once UnusedMember.Global - public sealed class WindowsFileSystemTests : {@class.Name}, IDisposable + public sealed class WindowsFileSystemTests : {@class.Name}, IDisposable {{ /// public override string BasePath => _directoryCleaner.BasePath; private readonly IDirectoryCleaner _directoryCleaner; - public WindowsFileSystemTests() : this(new MockFileSystem(o => + public WindowsFileSystemTests() : this(new Testably.Abstractions.Testing.MockFileSystem(o => o.SimulatingOperatingSystem(SimulationMode.Windows))) {{ }} - private WindowsFileSystemTests(MockFileSystem mockFileSystem) : base( + private WindowsFileSystemTests(Testably.Abstractions.Testing.MockFileSystem mockFileSystem) : base( new Test(OSPlatform.Windows), mockFileSystem, mockFileSystem.TimeSystem) diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj b/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj index 2b163db76..1243e07e0 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj +++ b/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj @@ -14,6 +14,7 @@ + diff --git a/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj b/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj index 2fcc4e1be..99a0b53ea 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj +++ b/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj @@ -5,6 +5,7 @@ + diff --git a/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs index 09c05b15c..0bcfef568 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs @@ -1,4 +1,5 @@ using System.IO; +using DirectoryInfoWrapper = Testably.Abstractions.FileSystem.DirectoryInfoWrapper; namespace Testably.Abstractions.Tests.Internal; diff --git a/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs index b88f7a0a4..89841c198 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs @@ -1,4 +1,6 @@ -namespace Testably.Abstractions.Tests.Internal; +using DriveInfoWrapper = Testably.Abstractions.FileSystem.DriveInfoWrapper; + +namespace Testably.Abstractions.Tests.Internal; public class DriveInfoWrapperTests { diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs index 999266a37..69083e95f 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs @@ -1,4 +1,5 @@ using System.IO; +using FileInfoWrapper = Testably.Abstractions.FileSystem.FileInfoWrapper; namespace Testably.Abstractions.Tests.Internal; diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs index 05a3781d4..5e9f02c15 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs @@ -1,4 +1,6 @@ using System.IO; +using DirectoryInfoWrapper = Testably.Abstractions.FileSystem.DirectoryInfoWrapper; +using FileInfoWrapper = Testably.Abstractions.FileSystem.FileInfoWrapper; namespace Testably.Abstractions.Tests.Internal; diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs index 88021a4a9..25059c6cd 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs @@ -1,4 +1,6 @@ -namespace Testably.Abstractions.Tests.Internal; +using FileSystemWatcherWrapper = Testably.Abstractions.FileSystem.FileSystemWatcherWrapper; + +namespace Testably.Abstractions.Tests.Internal; public class FileSystemWatcherWrapperTests { diff --git a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj index e23bf8b43..dfe773d0d 100644 --- a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj +++ b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj @@ -5,6 +5,7 @@ +