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
<PackageReference Include="TheMakarik.Testing.FileSystem" Version="2026.1.4" />
<PackageVersion Include="TheMakarik.Testing.FileSystem" Version="2026.1.4" />
<PackageReference Include="TheMakarik.Testing.FileSystem" />
paket add TheMakarik.Testing.FileSystem --version 2026.1.4
#r "nuget: TheMakarik.Testing.FileSystem, 2026.1.4"
#:package TheMakarik.Testing.FileSystem@2026.1.4
#addin nuget:?package=TheMakarik.Testing.FileSystem&version=2026.1.4
#tool nuget:?package=TheMakarik.Testing.FileSystem&version=2026.1.4
<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 | Versions 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. |
-
net8.0
- JetBrains.Annotations (>= 2025.2.4)
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.