Fluent.Unions.Xunit
1.1.0
dotnet add package Fluent.Unions.Xunit --version 1.1.0
NuGet\Install-Package Fluent.Unions.Xunit -Version 1.1.0
<PackageReference Include="Fluent.Unions.Xunit" Version="1.1.0" />
<PackageVersion Include="Fluent.Unions.Xunit" Version="1.1.0" />
<PackageReference Include="Fluent.Unions.Xunit" />
paket add Fluent.Unions.Xunit --version 1.1.0
#r "nuget: Fluent.Unions.Xunit, 1.1.0"
#:package Fluent.Unions.Xunit@1.1.0
#addin nuget:?package=Fluent.Unions.Xunit&version=1.1.0
#tool nuget:?package=Fluent.Unions.Xunit&version=1.1.0
![]()
Fluent.Unions.Xunit
Adds ResultAssert and OptionAssert for Result, Result<T> and Option<T> to xUnit v3. The methods return the value or the error, and a failure message names the actual state.
Installation
dotnet add package Fluent.Unions.Xunit
Usage
using Fluent.Unions.Xunit;
Result<Order> placed = await orders.PlaceAsync(request);
Order order = ResultAssert.Ok(placed);
// passes when the order was placed, and returns it
Result missing = await orders.DeleteAsync(unknownId);
NotFoundException error = ResultAssert.Error<NotFoundException>(missing);
// passes when the error is a NotFoundException, and returns it
OptionAssert.None(customer.Nickname);
// passes when the customer has no nickname
The assertions are static methods and not part of Assert, because the partial Assert class of xunit.v3.assert.source is compiled into each test project and cannot be extended from another assembly.
With your own result type
ResultAssert.Ok and ResultAssert.Error accept a result type you declare with [FluentResult<TError>], with a value and without (the value-less Result), and fail with the same messages. The untyped Error returns your declared error type. When that is an error union, Error<NotFound>(result) returns the case, and fails for another case. See Your own Result type.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fluent.Unions (>= 1.1.0)
- xunit.v3.assert (>= 4.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.