TheMakarik.Testing.FileSystem 2026.1.4

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

<div align="center"> <h1> <img src="img/icon.png" alt="TheMakarik Icon" width="48" height="48" style="vertical-align: middle;"> <span style="margin-left: 12px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;"> TheMakarik.Testing.FileSystem </span> </h1>

<p style="font-size: 1.2em; color: #666; margin-top: -10px; margin-bottom: 30px;"> 🧪 Fluent API for directory assertions and creations for your integrational tests in .NET </p>

</div>

Add the package

dotnet add package TheMakarik.Testing.FileSystem

Quick start (<a href="https://xunit.net/?tabs=cs">xUnit.net</a>)

1. Create new project
dotnet new xunit --language C#
2. Create a simple tests class
using System.Collections.Generic;
using System.IO;

namespace ReadMeExample

public interface IExplorer
{
    public IEnumerable<string> GetContent(string path);
}

public sealed class Explorer : IExplorer
{
    public IEnumerable<string> GetContent(string path)
    {
        ArgumentNullException.ThrowIfNull(path);
        
        if(!Directory.Exists(path))
            throw new DirectoryNotFoundException("Cannot get content from unexisting directory");
        
        return Directory.EnumerateFileSystemEntries(path);
    }
}
3. Create some tests
using TheMakarik.Testing.FileSystem;
using TheMakarik.Testing.FileSystem.Zip;
using ReadMeExample;

namespace ReadMeExample.Tests;

public sealed class ReadMeExampleTests
{
    private readonly string _mockFileFullPath;
    private readonly IFileSystem _fileSystem;
    private string _emptyDirectory;

    public ReadMeExampleTests()
    {
        _fileSystem = FileSystem.BeginBuilding()
            .AddRandomInTempRootName()
            .AddFile("mock.txt", "txt-file-with-content", out _mockFileFullPath)
            .AddDirectory("empty-directory")
            .AddDirectories(["first-directory", "second-directory"],
                (_, builder) => builder
                    .AddFile(Path.GetRandomFileName())
                    .AddFile("subdir-file.txt", "I am file from sub directory")
                    .AddFiles(["first-file", "second-file", "third-file"]))
            .AddDirectory("not-empty-directory", out _emptyDirectory)
            .AddZip("my-archive.zip", 
                builder =>  builder
                    .AddFile("README.md", "# Hello, I am my-archive.zip readme file")
                    .AddFile(Path.GetRandomFileName(), "my-archive file content"))
            .Build();
    }

    [Fact]
    public void GetContent_FromRoot_ReturnsRootContent()
    {
        //Arrange
        var systemUnderTests = new Explorer();
        //Act
        var result = systemUnderTests.GetContent(_fileSystem.Root);
        //Assert
        _fileSystem.Should()
            .ContentEquals(systemUnderTests.GetContent(_fileSystem.Root));
    }
    
    [Fact]
    public void GetContent_ReturnsContentOfTheDirectory()
    {
        //Arrange
        var systemUnderTests = new Explorer();
        //Act
        var result = systemUnderTests.GetContent(_emptyDirectory);
        //Assert
        _fileSystem
            .In(_emptyDirectory)
            .Should()
            .HasNoDirectoryContent()
            .ContentEquals(systemUnderTests.GetContent(_fileSystem.Root));
    }

    public void Dispose()
    {
        //Remove the root file system's directory
        _fileSystem.Dispose();
    }
}

Problem

The problem that the package resolve it's testing Explorer state machine between archives and directories at SolidZip, I guess this library will be useful for someone else

Documentation

Documentation is available in two languages:

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on TheMakarik.Testing.FileSystem:

Package Downloads
TheMakarik.Testing.FileSystem.SharpCompress

Simple package for creating and asserting file system at your integrational tests

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.1.4 126 2/22/2026
2026.1.3 134 2/9/2026
2026.1.2 104 2/9/2026
2026.1.1 103 2/9/2026
2026.1.0 107 2/8/2026
2026.0.1 114 1/16/2026
2026.0.0 116 1/14/2026