Skip to main content

Migration from TestableIO

Testably.Abstractions and TestableIO.System.IO.Abstractions share the same IFileSystem interface, so production code does not need to change when you switch testing libraries.

When to use which

The shared IFileSystem interface means production code is identical either way - this choice only affects tests. The core differentiator: Testably.Abstractions runs its full test suite against both MockFileSystem and RealFileSystem on every supported OS and against each SimulationMode, so the mock and the real OS stay in lock-step over time.

Pick Testably.Abstractions when you need a watcher, SafeFileHandle, multiple drives with size quotas, the ITimeSystem / IRandomSystem companions, or you want to exercise Linux/macOS/Windows behaviour from a single CI job. Pick TestableIO.System.IO.Abstractions when you're already using its MockFileData / MockDirectoryData to inspect or mutate the in-memory store directly - that surface has no equivalent here.

How to migrate

The migration only affects your test projects.

1. Swap the package

<!-- Remove -->
<PackageReference Include="TestableIO.System.IO.Abstractions.TestingHelpers" />
<!-- Add -->
<PackageReference Include="Testably.Abstractions.Testing" />

2. Update the test code

// Before (TestableIO)
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory("some-directory");
fileSystem.AddFile("some-file.txt", new MockFileData("content"));

// After (Testably) - option A: imperative
var fileSystem = new MockFileSystem();
fileSystem.Directory.CreateDirectory("some-directory");
fileSystem.File.WriteAllText("some-file.txt", "content");

// After (Testably) - option B: fluent initialization
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithSubdirectory("some-directory")
.WithFile("some-file.txt").Which(f => f
.HasStringContent("content"));

Production code keeps using IFileSystem exactly as before - no changes there.