CSharpFunctionalExtensions.FluentAssertions 2.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CSharpFunctionalExtensions.FluentAssertions --version 2.0.0
NuGet\Install-Package CSharpFunctionalExtensions.FluentAssertions -Version 2.0.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="CSharpFunctionalExtensions.FluentAssertions" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CSharpFunctionalExtensions.FluentAssertions --version 2.0.0
#r "nuget: CSharpFunctionalExtensions.FluentAssertions, 2.0.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.
// Install CSharpFunctionalExtensions.FluentAssertions as a Cake Addin
#addin nuget:?package=CSharpFunctionalExtensions.FluentAssertions&version=2.0.0

// Install CSharpFunctionalExtensions.FluentAssertions as a Cake Tool
#tool nuget:?package=CSharpFunctionalExtensions.FluentAssertions&version=2.0.0

CSharpFunctionalExtensions.FluentAssertions

  • NuGet Package CSharpFunctionalExtensions.FluentAssertions

A small set of extensions to make test assertions more fluent when using CSharpFunctionalExtensions! Wow!

Learn More

Dependencies

This library is compatible with .NET 6+. It requires the following minimum package versions:

CSharpFunctionalExtensons >= 2.37.0

FluentAssertions >= 6.10.0

Installation

This library is available on Nuget and can be installed with the .NET CLI using the following command:

dotnet add package CSharpFunctionalExtensions.FluentAssertions

Usage

Maybe Assertions

var maybe = Maybe.From("foo");

maybe.Should().HaveSomeValue(); // passes
maybe.Should().HaveValue("foo"); // passes
maybe.Should().HaveValue("bar"); // throws
maybe.Should().HaveNoValue(); // throws
Maybe<string> maybe = null;

maybe.Should().HaveNoValue(); // passes
maybe.Should().HaveValue("foo"); // throws

Result Assertions

var result = Result.Success();

result.Should().Succeed(); // passes
result.Should().Fail() // throws
var result = Result.Failure("error");

result.Should().Fail() // passes
result.Should().FailWith("error"); // passes
result.Should().FailWith("some other error"); // throws
result.Should().Succeed(); // throws

Generic Result of T Assertions

var result = Result.Success(420);

result.Should().Succeed(); // passes
result.Should().SucceedWith(420); // passes
result.Should().SucceedWith(69); // throws
result.Should().Fail(); // throws
var result = Result.Failure<string>("error");

result.Should().Fail() // passes
result.Should().FailWith("error"); // passes
result.Should().FailWith("some other error"); // throws
result.Should().Succeed(); // throws

Generic Result of T:Value and E:Error Assertions

var result = Result.Success<int, Exception>(420);

result.Should().Succeed(); // passes
result.Should().SucceedWith(420); // passes
result.Should().SucceedWith(69); // throws
result.Should().Fail(); // throws
result.Should().FailWith(new Exception("error")); // throws
var result = Result.Failure<int, Exception>(new Exception("error"));

result.Should().Fail(); // passes
result.Should().FailWith(new Exception("error")); // passes
result.Should().FailWith(new Exception("some other error")); // throws
result.Should().Succeed(); // throws
result.Should().SucceedWith(4680); // throws

UnitResult Assertions

var result = UnitResult.Success<string>();

result.Should().Succeed(); // passes
result.Should().Fail(); // throws
result.Should().FailWith("error"); // throws
var result = UnitResult.Failure("error");

result.Should().Fail(); // passes
result.Should().FailWith("error"); // passes
result.Should().Succeed(); // throws

Acknowledgements

Special thanks to Sean Wright for all his guidance and contributions over the design, development, and release of this project. His insights are invaluable! 😄

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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 CSharpFunctionalExtensions.FluentAssertions:

Package Downloads
Hopex.ApplicationServer.Commons

Hopex Application Server Commons

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CSharpFunctionalExtensions.FluentAssertions:

Repository Stars
KyleMcMaster/payroll-processor
A smorgasbord of modern .NET tech written with functional and asynchronous patterns
Version Downloads Last updated
3.0.0-prerelease-13-1 81 4/14/2024
2.0.0 28,474 8/11/2023
2.0.0-prerelease-12-1 58 4/14/2024
2.0.0-prerelease-11-1 453 8/11/2023
2.0.0-prerelease-10-1 620 5/18/2023
1.1.0 25,045 11/19/2022
1.1.0-prerelease-9-1 514 11/19/2022
1.0.1-prerelease-8-1 501 11/2/2022
1.0.0 1,002 10/21/2022
1.0.0-prerelease-7-1 524 10/21/2022
1.0.0-prerelease-6-1 497 10/9/2022
1.0.0-prerelease-5-1 507 8/26/2022
1.0.0-prerelease-4-1 504 8/13/2022
1.0.0-prerelease-3-1 545 4/29/2022
1.0.0-prerelease-2-1 559 4/16/2022