-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
The NullableBooleanAssertions do not support NotBe() at the moment.
Complete minimal example reproducing the issue
// Arrange
bool? input = true;
// Act
bool? result = false;
// Assert
result.Should().NotBe(input);Expected behavior:
No compiler error
Actual behavior:
Compiler error Argument type 'System.Nullable<bool>' is not assignable to parameter type 'bool':

Versions
- Which version of Fluent Assertions are you using? →
6.5.1 - Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.1. →
net6.0
Additional Information
I'm happy to provide a PR if you consider this feature useful. As far as I see, it should only be something like this in NullableBooleanAssertions:
public AndConstraint<TAssertions> NotBe(bool? expected, string because = "", params object[] becauseArgs)
{
Execute.Assertion
.ForCondition(Subject != expected)
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.", expected, Subject);
return new AndConstraint<TAssertions>((TAssertions)this);
}