Skip to content
Cyrille DUPUYDAUBY edited this page Feb 6, 2018 · 11 revisions

This page lists checks on various types.

Boolean

IsTrue()

Checks that the sut is true. Fails if false.

// this check succeeds
Check.That(true).IsTrue();
// this check fails
Check.That(false).IsTrue);

IsFalse()

Checks that the sut is false. Fails if true.

// this check succeeds
Check.That(false).IsFalse();
// this check fails
Check.That(true).IsFalse);

TimeSpan

IsLessThan(duration, unit)

Checks that the sut represents a duration which is shorter than the expected duration; fails if longer or equal. Uses the TimeUnit to express the unit of time (of the duration).

// This check succeeds.
Check.That(TimeSpan.FromSeconds(2)).IsLessThan(3, TimeUnit.Seconds);
// This check fails
Check.That(TimeSpan.FromDays(2)).IsLessThan(1, TimeUnit.Hours);
```
## IsGreaterThan(_duration_, _unit_)
Checks that the _sut_ represents a duration which is longer than the expected duration; fails if shorter or equal.
Uses the [TimeUnit](types#timeunit) to express the unit of time in (of the the duration).
````csharp
// This check succeeds.
Check.That(TimeSpan.FromSeconds(2)).IsGreaterThan(1, TimeUnit.Seconds);
// This check fails
Check.That(TimeSpan.FromDays(2)).IsGreaterThan(3, TimeUnit.Hours);
```
# EventWaitHandler
# IsSetWithin(_duration_, _unit_)
Checks that the _sut_ is an **EventWaitHandler** that will be in **set** state within the given _duration_.
Uses the [TimeUnit](types#timeunit) to express the unit of time in (of the the duration).

````csharp
// Syntax example
var sut = new EventWaitHandle(true, EventResetMode.AutoReset);
Check.That(sut).IsSetWithin(1, TimeUnit.Milliseconds);
// This check fails (event has been auto reseted by previous check)
Check.That(sut).IsSetWithin(1, TimeUnit.Milliseconds);
```