Testably.Abstractions
10.3.0
Prefix Reserved
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package Testably.Abstractions --version 10.3.0
NuGet\Install-Package Testably.Abstractions -Version 10.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Testably.Abstractions" Version="10.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Testably.Abstractions" Version="10.3.0" />
<PackageReference Include="Testably.Abstractions" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Testably.Abstractions --version 10.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Testably.Abstractions, 10.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Testably.Abstractions@10.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Testably.Abstractions&version=10.3.0
#tool nuget:?package=Testably.Abstractions&version=10.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Testably.Abstractions
Injectable abstractions for the static parts of the .NET base class library (BCL) - file system, time and randomness - with feature-complete in-memory mocks for tests.
📖 Full documentation: docs.testably.org/Abstractions
Quick example
public class ReportService(IFileSystem fileSystem)
{
public void Save(string content)
{
fileSystem.Directory.CreateDirectory("reports");
fileSystem.File.WriteAllText("reports/latest.xml", content);
}
}
[Fact]
public async Task Save_WritesReportToReportsFolder()
{
var fileSystem = new MockFileSystem();
var sut = new ReportService(fileSystem);
sut.Save("<report />");
await Expect.That(fileSystem.File.ReadAllText("reports/latest.xml"))
.IsEqualTo("<report />");
}
Install
dotnet add package Testably.Abstractions
dotnet add package Testably.Abstractions.Testing
Then register the implementations in your DI container - see Getting Started.
Packages
| Package | Purpose |
|---|---|
Testably.Abstractions |
Production interfaces (IFileSystem, ITimeSystem, IRandomSystem) |
Testably.Abstractions.Testing |
MockFileSystem, MockTimeSystem, MockRandomSystem |
Testably.Abstractions.Compression |
Zip / ZipArchive extension methods on IFileSystem |
Testably.Abstractions.AccessControl |
GetAccessControl / SetAccessControl on files and directories |
Already on TestableIO?
Testably.Abstractions shares the IFileSystem interface with TestableIO.System.IO.Abstractions, so production code stays untouched. See the migration guide.
Contributing
Issues and pull requests are welcome - see CONTRIBUTING.md and the issue tracker.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core |