Skip to content

Extension to Fluent Assertions that aids in testing Resultful and other libraries with Union types

License

Notifications You must be signed in to change notification settings

Resultful/FluentAssertions.Resultful

Repository files navigation

FluentAssertions.Resultful

Extension to FluentAssertions which improves the utility of Resultful. It does this by providing extension methods which fail with useful errors when Result values are found and acted upon. The installation instructions for this library can be found here

FluentAssertions.OneOf

This project also contains another package. Extension to FluentAssertions which improves the usage of OneOf to allow easier unit testing. It does this by providing extensions which fail with useful errors when OneOf like values are found and acted upon.

Installation

Instructions to install using your appropriate package manager can be found here

Usage

var testValue = OneOf<int, string, DateTime>.FromT1("Test Value");

testValue.Should().Be<string>()
    .And.Should().Be("Test Value");

This asserts the type of the underlying value in the OneOf and returns it is the assertion is successful. The type passed into the function can be anything, even if it is not present in the given OneOf. This is a limitation of the library that reduces the type safety, but due to the fact that its intended usage is inside of a unit test any failures would be detected quickly. They should also be relatively easy to fix too.

About

Extension to Fluent Assertions that aids in testing Resultful and other libraries with Union types

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages