A small set of extensions to make test assertions more fluent when using CSharpFunctionalExtensions! Wow!
This library is compatible with .NET 6+.
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
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
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
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
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