CSharpFunctionalExtensions.FluentAssertions 2.0.0-prerelease-12-1

This is a prerelease version of CSharpFunctionalExtensions.FluentAssertions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package CSharpFunctionalExtensions.FluentAssertions --version 2.0.0-prerelease-12-1                
NuGet\Install-Package CSharpFunctionalExtensions.FluentAssertions -Version 2.0.0-prerelease-12-1                
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-prerelease-12-1" />                
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-prerelease-12-1                
#r "nuget: CSharpFunctionalExtensions.FluentAssertions, 2.0.0-prerelease-12-1"                
#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-prerelease-12-1&prerelease

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

CSharpFunctionalExtensions.FluentAssertions

  • NuGet Package CSharpFunctionalExtensions.FluentAssertions

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

Star History

<a href="https://star-history.com/#NitroDevs/CSharpFunctionalExtensions.FluentAssertions&Date"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=NitroDevs/CSharpFunctionalExtensions.FluentAssertions&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=NitroDevs/CSharpFunctionalExtensions.FluentAssertions&type=Date" /> <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=NitroDevs/CSharpFunctionalExtensions.FluentAssertions&type=Date" /> </picture> </a>

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 (3)

Showing the top 3 NuGet packages that depend on CSharpFunctionalExtensions.FluentAssertions:

Package Downloads
Hopex.ApplicationServer.Commons

Hopex Application Server Commons

Zafiro.FileSystem.Actions

The Cross-platform Crema for .NET Devs

Zafiro.FileSystem.VNext

Turns your filesystem problems into a breadcrumb

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 334 4/14/2024
2.0.0 69,844 8/11/2023
2.0.0-prerelease-12-1 99 4/14/2024
2.0.0-prerelease-11-1 484 8/11/2023
2.0.0-prerelease-10-1 720 5/18/2023
1.1.0 34,346 11/19/2022
1.1.0-prerelease-9-1 552 11/19/2022
1.0.1-prerelease-8-1 538 11/2/2022
1.0.0 1,118 10/21/2022
1.0.0-prerelease-7-1 549 10/21/2022
1.0.0-prerelease-6-1 533 10/9/2022
1.0.0-prerelease-5-1 538 8/26/2022
1.0.0-prerelease-4-1 535 8/13/2022
1.0.0-prerelease-3-1 584 4/29/2022
1.0.0-prerelease-2-1 587 4/16/2022