False Constraint
FalseConstraint tests that a value is false. Use this constraint when asserting that a boolean condition or
expression evaluates to false.
Usage
Is.False
Is.Not.False // equivalent to Is.True
Examples
[Test]
public void FalseConstraint_Examples()
{
Assert.That(2 + 2 == 5, Is.False);
var isDisabled = false;
Assert.That(isDisabled, Is.False);
ICollection<int> list = new List<int>();
Assert.That(list.IsReadOnly, Is.False);
// With nullable booleans
bool? isDeleted = false;
Assert.That(isDeleted, Is.False);
}
Notes
Is.Not.Falseis equivalent toIs.Truefor non-nullable booleans.- For nullable booleans (
bool?),Is.Falseonly passes when the value is exactlyfalse, not when it'snull.