https://github.com/nitrodevs/csharpfunctionalextensions.fluentassertions
A small set of extensions to make test assertions more fluent when using CSharpFunctionalExtensions! Wow!
https://github.com/nitrodevs/csharpfunctionalextensions.fluentassertions
functional-programming hacktoberfest monad tdd testing
Last synced: 2 months ago
JSON representation
A small set of extensions to make test assertions more fluent when using CSharpFunctionalExtensions! Wow!
- Host: GitHub
- URL: https://github.com/nitrodevs/csharpfunctionalextensions.fluentassertions
- Owner: NitroDevs
- License: mit
- Created: 2021-12-30T16:40:07.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-12-01T10:33:19.000Z (4 months ago)
- Last Synced: 2026-01-09T07:50:45.853Z (2 months ago)
- Topics: functional-programming, hacktoberfest, monad, tdd, testing
- Language: C#
- Homepage:
- Size: 172 KB
- Stars: 24
- Watchers: 5
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# CSharpFunctionalExtensions.FluentAssertions
- [](https://www.nuget.org/packages/CSharpFunctionalExtensions.FluentAssertions) **CSharpFunctionalExtensions.FluentAssertions**
A small set of extensions to make test assertions more fluent when using CSharpFunctionalExtensions! Wow!
## Star History
## Learn More
* [Announcing CSharpFunctionalExtensions.FluentAssertions](https://www.kylemcmaster.com/blog/announcing-csharpfunctionalextensions-fluentassertions)
## Dependencies
This library is compatible with .NET 6+. It requires the following minimum package versions:
CSharpFunctionalExtensons >= 3.0.0
FluentAssertions >= 7.2.0
## Installation
This library is available on Nuget and can be installed with the .NET CLI using the following command:
```bash
dotnet add package CSharpFunctionalExtensions.FluentAssertions
```
## Usage
### Maybe Assertions
```csharp
var maybe = Maybe.From("foo");
maybe.Should().HaveSomeValue(); // passes
maybe.Should().HaveValue("foo"); // passes
maybe.Should().HaveValue("bar"); // throws
maybe.Should().HaveNoValue(); // throws
```
```csharp
Maybe maybe = null;
maybe.Should().HaveNoValue(); // passes
maybe.Should().HaveValue("foo"); // throws
```
### Result Assertions
```csharp
var result = Result.Success();
result.Should().Succeed(); // passes
result.Should().Fail() // throws
```
```csharp
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
```csharp
var result = Result.Success(420);
result.Should().Succeed(); // passes
result.Should().SucceedWith(420); // passes
result.Should().SucceedWith(69); // throws
result.Should().Fail(); // throws
```
```csharp
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:Value and E:Error Assertions
```csharp
var result = Result.Success(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
```
```csharp
var result = Result.Failure(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
```csharp
var result = UnitResult.Success();
result.Should().Succeed(); // passes
result.Should().Fail(); // throws
result.Should().FailWith("error"); // throws
```
```csharp
var result = UnitResult.Failure("error");
result.Should().Fail(); // passes
result.Should().FailWith("error"); // passes
result.Should().Succeed(); // throws
```
## Related Projects
* [CSharpFunctionalExtensions](https://github.com/vkhorikov/CSharpFunctionalExtensions)
* [FluentAssertions.CSharpFunctionalExtensions](https://github.com/pedromtcosta/FluentAssertions.CSharpFunctionalExtensions)
* [Typescript Functional Extensions](https://github.com/seangwright/typescript-functional-extensions)
## Acknowledgements
Special thanks to [Sean Wright](https://github.com/seangwright) for all his guidance and contributions over the design, development, and release of this project. His insights are invaluable! :smile: