A small set of extensions to make test assertions more fluent when using CSharpFunctionalExtensions! Wow!
This library is compatible with .NET 6+. It requires the following minimum package versions:
CSharpFunctionalExtensons >= 3.0.0
FluentAssertions >= 7.2.0
This library is available on Nuget and can be installed with the .NET CLI using the following command:
dotnet add package CSharpFunctionalExtensions.FluentAssertionsvarmaybe=Maybe.From("foo");maybe.Should().HaveSomeValue();// passesmaybe.Should().HaveValue("foo");// passesmaybe.Should().HaveValue("bar");// throwsmaybe.Should().HaveNoValue();// throwsMaybe<string>maybe=null;maybe.Should().HaveNoValue();// passesmaybe.Should().HaveValue("foo");// throwsvarresult=Result.Success();result.Should().Succeed();// passesresult.Should().Fail()// throwsvarresult=Result.Failure("error");result.Should().Fail()// passes
result.Should().FailWith("error");// passesresult.Should().FailWith("some other error");// throwsresult.Should().Succeed();// throwsvarresult=Result.Success(420);result.Should().Succeed();// passesresult.Should().SucceedWith(420);// passesresult.Should().SucceedWith(69);// throwsresult.Should().Fail();// throwsvarresult=Result.Failure<string>("error");result.Should().Fail()// passes
result.Should().FailWith("error");// passesresult.Should().FailWith("some other error");// throwsresult.Should().Succeed();// throwsvarresult=Result.Success<int,Exception>(420);result.Should().Succeed();// passesresult.Should().SucceedWith(420);// passesresult.Should().SucceedWith(69);// throwsresult.Should().Fail();// throwsresult.Should().FailWith(newException("error"));// throwsvarresult=Result.Failure<int,Exception>(newException("error"));result.Should().Fail();// passesresult.Should().FailWith(newException("error"));// passesresult.Should().FailWith(newException("some other error"));// throwsresult.Should().Succeed();// throwsresult.Should().SucceedWith(4680);// throwsvarresult=UnitResult.Success<string>();result.Should().Succeed();// passesresult.Should().Fail();// throwsresult.Should().FailWith("error");// throwsvarresult=UnitResult.Failure("error");result.Should().Fail();// passesresult.Should().FailWith("error");// passesresult.Should().Succeed();// throws- CSharpFunctionalExtensions
- FluentAssertions.CSharpFunctionalExtensions
- Typescript Functional Extensions
Special thanks to Sean Wright for all his guidance and contributions over the design, development, and release of this project. His insights are invaluable! 😄