Skip to main content

Boolean

Describes the possible expectations for boolean values.

Equality

You can verify, that the bool is equal to another one or not:

bool subject = false;

await Expect.That(subject).IsEqualTo(false);
await Expect.That(subject).IsNotEqualTo(true);

True / False

You can verify, that the bool is true or false:

await Expect.That(false).IsFalse();
await Expect.That(true).IsTrue();

The negation is only available for nullable booleans:

bool? subject = null;

await Expect.That(subject).IsNotFalse()
.Because("it could be true or null");
await Expect.That(subject).IsNotTrue()
.Because("it could be false or null");

Implication

You can verify, that a implies b (find here a mathematical explanation):

bool a = false;
bool b = true;

await Expect.That(a).Implies(b);