From f0bc65ee622e91d020468bfc8cc8b82c9d98a1aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:26:49 +0000 Subject: [PATCH 1/3] Initial plan From 8909b5d34fef69c02076cf2d86677e2053b072b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:33:34 +0000 Subject: [PATCH 2/3] docs: add section clarifying relationship with TestableIO.System.IO.Abstractions Co-authored-by: vbreuss <3438234+vbreuss@users.noreply.github.com> --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index 31a1005e6..4422537ad 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,51 @@ In addition, the following interfaces are defined: - The `IRandomSystem` interface abstracts away functionality related to randomness: `Random` methods implement a thread-safe Shared instance also under .NET Framework and `Guid` methods allow creating new GUIDs. +## Relationship with TestableIO.System.IO.Abstractions + +This library uses the same interfaces as [TestableIO.System.IO.Abstractions](https://github.com/TestableIO/System.IO.Abstractions), which means you can switch between the two testing libraries **without changing your production code**. Both libraries provide `IFileSystem` implementations, but with different testing capabilities and API surfaces. + +### When to use Testably.Abstractions vs TestableIO +- **Use Testably.Abstractions** if you need: + - Advanced testing scenarios (FileSystemWatcher, SafeFileHandles, multiple drives) + - Additional abstractions (ITimeSystem, IRandomSystem) + - Cross-platform file system simulation (Linux, MacOS, Windows) + - More extensive and consistent behavior validation + - Active development and new features + +- **Use TestableIO.System.IO.Abstractions** if you need: + - Basic file system mocking capabilities + - Direct manipulation of stored file entities (MockFileData, MockDirectoryData) + - Established codebase with existing TestableIO integration + +### Migrating from TestableIO +Switching from TestableIO to Testably only requires changes in your test projects: + +1. Replace the NuGet package reference in your test projects: + ```xml + + + + + ``` + +2. Update your test code to use the new `MockFileSystem`: + ```csharp + // Before (TestableIO) + var fileSystem = new MockFileSystem(); + fileSystem.AddDirectory("some-directory"); + fileSystem.AddFile("some-file.txt", new MockFileData("content")); + + // After (Testably) + var fileSystem = new MockFileSystem(); + fileSystem.Directory.CreateDirectory("some-directory"); + fileSystem.File.WriteAllText("some-file.txt", "content"); + // or using fluent initialization: + fileSystem.Initialize().WithSubdirectory("some-directory").WithFile("some-file.txt").Which(f => f.HasStringContent("content")); + ``` + +Your production code using `IFileSystem` remains unchanged. + ## Example Use the interfaces and their default implementations using your prefered dependency injection method, e.g.: ```csharp From 564b8eb3bd13e951036816f7b36a7c8850d3524d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Tue, 12 Aug 2025 21:45:25 +0200 Subject: [PATCH 3/3] Move section to the bottom --- README.md | 93 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 4422537ad..65d62b3b5 100644 --- a/README.md +++ b/README.md @@ -24,51 +24,6 @@ In addition, the following interfaces are defined: - The `IRandomSystem` interface abstracts away functionality related to randomness: `Random` methods implement a thread-safe Shared instance also under .NET Framework and `Guid` methods allow creating new GUIDs. -## Relationship with TestableIO.System.IO.Abstractions - -This library uses the same interfaces as [TestableIO.System.IO.Abstractions](https://github.com/TestableIO/System.IO.Abstractions), which means you can switch between the two testing libraries **without changing your production code**. Both libraries provide `IFileSystem` implementations, but with different testing capabilities and API surfaces. - -### When to use Testably.Abstractions vs TestableIO -- **Use Testably.Abstractions** if you need: - - Advanced testing scenarios (FileSystemWatcher, SafeFileHandles, multiple drives) - - Additional abstractions (ITimeSystem, IRandomSystem) - - Cross-platform file system simulation (Linux, MacOS, Windows) - - More extensive and consistent behavior validation - - Active development and new features - -- **Use TestableIO.System.IO.Abstractions** if you need: - - Basic file system mocking capabilities - - Direct manipulation of stored file entities (MockFileData, MockDirectoryData) - - Established codebase with existing TestableIO integration - -### Migrating from TestableIO -Switching from TestableIO to Testably only requires changes in your test projects: - -1. Replace the NuGet package reference in your test projects: - ```xml - - - - - ``` - -2. Update your test code to use the new `MockFileSystem`: - ```csharp - // Before (TestableIO) - var fileSystem = new MockFileSystem(); - fileSystem.AddDirectory("some-directory"); - fileSystem.AddFile("some-file.txt", new MockFileData("content")); - - // After (Testably) - var fileSystem = new MockFileSystem(); - fileSystem.Directory.CreateDirectory("some-directory"); - fileSystem.File.WriteAllText("some-file.txt", "content"); - // or using fluent initialization: - fileSystem.Initialize().WithSubdirectory("some-directory").WithFile("some-file.txt").Which(f => f.HasStringContent("content")); - ``` - -Your production code using `IFileSystem` remains unchanged. - ## Example Use the interfaces and their default implementations using your prefered dependency injection method, e.g.: ```csharp @@ -196,3 +151,51 @@ fileSystem.WithDrive(d => d.SetTotalSize(20)); // this will throw an IOException that there is not enough space on the disk. fileSystem.File.WriteAllText("foo", "some text longer than 20 bytes"); ``` + +## Relationship with TestableIO.System.IO.Abstractions + +This library uses the same interfaces as [TestableIO.System.IO.Abstractions](https://github.com/TestableIO/System.IO.Abstractions), which means you can switch between the two testing libraries **without changing your production code**. Both libraries provide `IFileSystem` implementations, but with different testing capabilities and API surfaces. + +### When to use Testably.Abstractions vs TestableIO +- **Use Testably.Abstractions** if you need: + - Advanced testing scenarios (FileSystemWatcher, SafeFileHandles, multiple drives) + - Additional abstractions (ITimeSystem, IRandomSystem) + - Cross-platform file system simulation (Linux, MacOS, Windows) + - More extensive and consistent behavior validation + - Active development and new features + +- **Use TestableIO.System.IO.Abstractions** if you need: + - Basic file system mocking capabilities + - Direct manipulation of stored file entities (MockFileData, MockDirectoryData) + - Established codebase with existing TestableIO integration + +### Migrating from TestableIO +Switching from TestableIO to Testably only requires changes in your test projects: + +1. Replace the NuGet package reference in your test projects: + ```xml + + + + + ``` + +2. Update your test code to use the new `MockFileSystem`: + ```csharp + // Before (TestableIO) + var fileSystem = new MockFileSystem(); + fileSystem.AddDirectory("some-directory"); + fileSystem.AddFile("some-file.txt", new MockFileData("content")); + + // After (Testably) + var fileSystem = new MockFileSystem(); + fileSystem.Directory.CreateDirectory("some-directory"); + fileSystem.File.WriteAllText("some-file.txt", "content"); + // or using fluent initialization: + fileSystem.Initialize() + .WithSubdirectory("some-directory") + .WithFile("some-file.txt").Which(f => f + .HasStringContent("content")); + ``` + +Your production code using `IFileSystem` remains unchanged.