Bitbound.SystemAbstractions.TestUtilities 1.0.7

dotnet add package Bitbound.SystemAbstractions.TestUtilities --version 1.0.7
                    
NuGet\Install-Package Bitbound.SystemAbstractions.TestUtilities -Version 1.0.7
                    
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="Bitbound.SystemAbstractions.TestUtilities" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitbound.SystemAbstractions.TestUtilities" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="Bitbound.SystemAbstractions.TestUtilities" />
                    
Project file
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 Bitbound.SystemAbstractions.TestUtilities --version 1.0.7
                    
#r "nuget: Bitbound.SystemAbstractions.TestUtilities, 1.0.7"
                    
#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 Bitbound.SystemAbstractions.TestUtilities@1.0.7
                    
#: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=Bitbound.SystemAbstractions.TestUtilities&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=Bitbound.SystemAbstractions.TestUtilities&version=1.0.7
                    
Install as a Cake Tool

Bitbound.SystemAbstractions.TestUtilities

In-memory fakes and xUnit helpers for testing services that depend on Bitbound.SystemAbstractions. Unlike the main package, the types here are public so tests can build and inspect them directly.

Install

dotnet add package Bitbound.SystemAbstractions.TestUtilities

FakeFileSystem

FakeFileSystem implements IFileSystem and IFileAccessPermissions entirely in memory. It mirrors the real implementation's behavior, including parent-directory creation, FileMode/FileAccess/FileShare rules on streams, zip extraction, and the exception types and messages the BCL throws.

var fileSystem = new FakeFileSystem();
fileSystem.AddFile("/data/config.json", """{"port": 5000}""");
fileSystem.AddDrive("/mnt/data", name: "data", totalSize: 1_000_000, totalFreeSpace: 400_000);
fileSystem.SetResolvedFilePath("dotnet", "/usr/share/dotnet/dotnet");

Assert.True(fileSystem.FileExists("/data/config.json"));

Seeding and inspection helpers:

Member Purpose
AddFile(path, content, ...) Seed a file from a string or byte[], creating parent directories.
AddDirectory(path, ...) Seed a directory and its parents.
AddDrive(rootPath, ...) Seed an entry returned by GetDrives().
SetResolvedFilePath(fileName, path) Program the answer to ResolveFilePath(fileName).
SetVersionInfoSource(path, sourcePath) Back GetFileVersionInfo(path) with a real file's version info.

The constructor takes directorySeparator (/ by default, \ for Windows-style paths) and isCaseSensitive (false by default, matching Windows).

FakeRegistry

FakeRegistry implements IRegistryManager against a memory-backed tree, and applies the same value-kind inference and error semantics as the Windows registry, so code that reads and writes keys is testable on any operating system.

var registry = new FakeRegistry();
registry.SetValue(@"HKEY_CURRENT_USER\Software\MyApp", "InstallDir", @"C:\app");

registry.CurrentUser.OpenSubKey(@"Software\MyApp")!.GetValue("InstallDir");

Seeding and inspection helpers: CreateKey(path), SetValue(keyPath, name, value[, kind]), KeyExists(path), GetValueNames(path), ValueExists(keyPath, name), and Reset(). The constructor takes isCaseSensitive (false by default, matching Windows). Both HKEY_CURRENT_USER and HKCU style prefixes resolve to the same hive, as do the other five hives.

Swap the fakes in over the real registrations:

var services = new ServiceCollection();
services.AddSystemAbstractions();
services.AddSingleton<IFileSystem>(fileSystem);
services.AddSingleton<IFileAccessPermissions>(fileSystem);
services.AddSingleton<IRegistryManager>(registry);

Platform-specific facts and theories

Skip attributes for tests that only work on one operating system. They set Skip at construction time when the current operating system does not match, so the test reports as skipped rather than failed.

WindowsOnlyFactAttribute, WindowsOnlyTheoryAttribute, LinuxOnlyFactAttribute, LinuxOnlyTheoryAttribute, MacOnlyFactAttribute, MacOnlyTheoryAttribute.

Session-shaped variants gate on the desktop session rather than the operating system alone: InteractiveWindowsFactAttribute (interactive Windows session, not a CI runner), WaylandOnlyFactAttribute (WAYLAND_DISPLAY or XDG_SESSION_TYPE=wayland), and MacKeychainIntegrationFactAttribute (interactive macOS session, not a CI runner).

[WindowsOnlyFact]
public void Set_WhenAclIsApplied_UpdatesTheFile()
{
  // ...
}

Logging

XunitLogger, XunitLogger<T>, and XunitLoggerProvider implement Microsoft.Extensions.Logging on top of xUnit's ITestOutputHelper, so ILogger output from the services under test lands in the test's output.

services.AddSingleton<ILoggerProvider>(new XunitLoggerProvider(testOutputHelper));

XunitLogger<T> uses typeof(T).Name as the category. BeginScope nests, and each entry lists its open scopes from innermost to outermost.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 116 9/8/2026
1.0.5 100 9/8/2026