MackySoft.Testing.Xunit 0.1.0

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

MackySoft.Testing.Xunit

NuGet License: MIT

MackySoft.Testing.Xunit provides xUnit assertions for filesystem and JSON test contracts.

The package targets net8.0 and depends on MackySoft.Testing.IO and xunit.assert. Assertion failures include the inspected path or JSON location where applicable.

Installation

Install a pinned version from nuget.org:

dotnet add package MackySoft.Testing.Xunit --version <version>

Filesystem Assertions

using MackySoft.Testing.Xunit.IO;

FileSystemAssert.ForFile(resultPath)
    .Exists()
    .IsUnderDirectory(testDirectory)
    .HasFileName("result.json")
    .HasExtension("json");

FileSystemAssert.ForDirectory(testDirectory)
    .HasDirectory("assets")
    .HasFile("result.json")
    .MatchesExactly();

Path equality and containment assertions normalize absolute paths, symbolic links, and macOS /private aliases before comparison. Directory child assertions use portable single-segment names and can require the exact immediate entry set.

JSON Assertions

using System.Text.Json;
using MackySoft.Testing.Xunit.Json;

using JsonDocument document = JsonDocument.Parse(json);

JsonAssert.For(document.RootElement)
    .HasString("status", "ready")
    .HasInt32("attempt", 2)
    .HasProperty("items", 0, item =>
        item.HasString("name", "first"));

The fluent assertion rejects duplicate object property names and reports the containing object path.

For a small reusable structure assertion, build an in-memory schema:

JsonSchemaNode schema = JsonSchemaNode.Object(root => root
    .Required("status", JsonSchemaNode.Value(JsonSchemaType.String))
    .RequiredArrayOfObject("items", item => item
        .Required("name", JsonSchemaNode.Value(JsonSchemaType.String))),
    allowAdditionalProperties: false);

JsonAssert.For(document.RootElement)
    .MatchesSchema(schema, "result document");

This model is an assertion helper, not an implementation or parser of the JSON Schema specification.

Golden JSON

GoldenJsonAssert.EqualFile(expectedJsonPath, actualJson);

Golden comparison first validates both inputs as JSON and then compares their text ordinally. Whitespace, property order, and line endings are part of the contract. Golden files must be valid UTF-8 without a byte-order mark, and callers provide their path explicitly.

Repository and Support

Source, issues, and support are available in the MackySoft .NET Foundations repository.

License

This package is under the MIT License.

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

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
0.1.0 639 8/9/2026