Skip to content

A dotnet testing library, allowing you to test code that uses Futurum.Core

License

Notifications You must be signed in to change notification settings

futurum-dev/dotnet.futurum.test

Repository files navigation

Futurum.Test

license CI Coverage Status NuGet version

A dotnet testing library, allowing you to test code that uses Futurum.Core. It contains a comprehensive set of assertions for testing Futurum.Core types.

Result

ShouldBeSuccess

Checks that the result is a success.

result.ShouldBeSuccess();

ShouldBeSuccessWithValue

Checks that the result is a success and that the value is equal to the expected value.

result.ShouldBeSuccessWithValue(expectedValue);

ShouldBeSuccessWithValueEquivalentTo

Checks that the result is a success and that the value is equivalent to the expected value.

result.ShouldBeSuccessWithValueEquivalentTo(equivalentValue);

ShouldBeSuccessWithValueEquivalentToAsync

Checks that the result is a success and that the value is equivalent to the expected value.

result.ShouldBeSuccessWithValueEquivalentToAsync(numbers);

NOTE This method works with IAsyncEnumerable<T>.

ShouldBeSuccessWithValueAssertion

Checks that the result is a success and that the value passes the assertions specified.

result.ShouldBeSuccessWithValueAssertion(x => x.Should().Be(expectedValue));

ShouldBeFailure

Checks that the result is a failure.

result.ShouldBeFailure();

ShouldBeFailureWithError

Checks that the result is a failure and that the error is equal to the expected error.

result.ShouldBeFailureWithError(expectedErrorMessage);

ShouldBeFailureWithErrorSafe

Checks that the result is a failure and that the error is equal to the expected error.

result.ShouldBeFailureWithErrorSafe(expectedErrorMessage);

NOTE This will call ToErrorStringSafe on the error.

ShouldBeFailureWithErrorContaining

Checks that the result is a failure and that the error contains the expected error.

result.ShouldBeFailureWithErrorContaining(expectedErrorMessage);

ShouldBeFailureWithErrorSafeContaining

Checks that the result is a failure and that the error contains the expected error.

result.ShouldBeFailureWithErrorContaining(expectedErrorMessage);

NOTE This will call ToErrorStringSafe on the error.

Option

ShouldBeHasValue

Check that the option has a value.

option.ShouldBeHasValue();

ShouldBeHasValueWithValue

Check that the option has a value and that the value is equal to the expected value.

option.ShouldBeHasValueWithValue(expectedValue);

ShouldBeHasValueWithValueEquivalentTo

Check that the option has a value and that the value is equivalent to the expected value.

option.ShouldBeHasValueWithValueEquivalentTo(equivalentValue);

ShouldBeHasValueWithValueAssertion

Check that the option has a value and that the value passes the assertions specified.

option.ShouldBeHasValueWithValueAssertion(x => x.Should().Be(expectedValue));

ShouldBeHasNoValue

Check that the option has no value.

option.ShouldBeHasNoValue();