Trellis.Testing 3.0.0-alpha.100

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

Testing Utilities

NuGet Package

FluentAssertions extensions, test builders, and fake implementations for testing Railway Oriented Programming patterns with Trellis.

Installation

dotnet add package Trellis.Testing

Quick Start

Result Assertions

using Trellis.Testing;

// Success
result.Should().BeSuccess()
    .Which.Value.Should().Be(expected);

// Failure by type
result.Should().BeFailureOfType<NotFoundError>()
    .Which.Should().HaveDetail("User not found");

Validation Error Assertions

result.Should()
    .BeFailureOfType<ValidationError>()
    .Which.Should()
    .HaveFieldCount(3)
    .And.HaveFieldError("firstName")
    .And.HaveFieldError("email")
    .And.HaveFieldErrorWithDetail("age", "Must be 18 or older");

Maybe Assertions

maybe.Should().HaveValue().Which.Should().Be("hello");
maybe.Should().BeNone();

Test Builders

using Trellis.Testing.Builders;

// Quick Result creation
var result = ResultBuilder.NotFound<User>("User not found");

// Complex validation errors
var error = ValidationErrorBuilder.Create()
    .WithFieldError("email", "Email is required")
    .WithFieldError("age", "Must be 18 or older")
    .Build();

Fake Repository

using Trellis.Testing.Fakes;

var repo = new FakeRepository<User, UserId>();
var sut = new UserService(repo);

var result = await sut.CreateUserAsync(command, CancellationToken.None);

result.Should().BeSuccess();
repo.Exists(result.Value.Id).Should().BeTrue();
repo.PublishedEvents.Should().ContainSingle()
    .Which.Should().BeOfType<UserCreatedEvent>();

Assertion API Reference

Result

Method Description
BeSuccess() Assert result is success
BeFailure() Assert result is failure
BeFailureOfType<TError>() Assert failure with specific error type
HaveValue(expected) Assert success value equals expected
HaveValueMatching(predicate) Assert success value satisfies predicate
HaveValueEquivalentTo(expected) Assert success value using structural comparison
HaveErrorCode(code) Assert failure has specific error code
HaveErrorDetail(detail) Assert failure has specific error detail
HaveErrorDetailContaining(substring) Assert failure error detail contains substring

Async variants (BeSuccessAsync, BeFailureAsync, BeFailureOfTypeAsync) are available for Task<Result<T>> and ValueTask<Result<T>>.

Error

Method Description
Be(expected) Assert error equals expected (by Code)
HaveCode(code) Assert error code
HaveDetail(detail) Assert error detail message
HaveDetailContaining(substring) Assert error detail contains substring
HaveInstance(instance) Assert error instance identifier
BeOfType<TError>() Assert error is of a specific type

ValidationError

Method Description
HaveFieldError(fieldName) Assert field has error
HaveFieldErrorWithDetail(field, detail) Assert field has specific error
HaveFieldCount(count) Assert number of field errors

Maybe

Method Description
HaveValue() Assert Maybe has a value
BeNone() Assert Maybe has no value
HaveValueEqualTo(expected) Assert value equals expected
HaveValueMatching(predicate) Assert value satisfies predicate
HaveValueEquivalentTo(expected) Assert value using structural comparison

Before & After

Before After
result.IsSuccess.Should().BeTrue() result.Should().BeSuccess()
result.Error.Should().BeOfType<NotFoundError>() result.Should().BeFailureOfType<NotFoundError>()
maybe.HasValue.Should().BeTrue() maybe.Should().HaveValue()

License

MIT — see LICENSE for details.

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
3.0.0-alpha.100 0 3/4/2026
3.0.0-alpha.99 28 3/4/2026
3.0.0-alpha.98 33 3/3/2026
3.0.0-alpha.95 40 3/2/2026
3.0.0-alpha.94 45 3/2/2026
3.0.0-alpha.93 44 3/1/2026
3.0.0-alpha.92 53 2/28/2026
3.0.0-alpha.83 39 2/27/2026