-
Notifications
You must be signed in to change notification settings - Fork 53
Misc checks
Cyrille DUPUYDAUBY edited this page Feb 6, 2018
·
11 revisions
This page lists checks on various types.
Checks that the sut is true. Fails if false.
// this check succeeds
Check.That(true).IsTrue();
// this check fails
Check.That(false).IsTrue);
Checks that the sut is false. Fails if true.
// this check succeeds
Check.That(false).IsFalse();
// this check fails
Check.That(true).IsFalse);
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);
```
- Welcome
- How to start
- Customising error messages
-
Check.That
- All (Equality, Type)
- Reference types
- Members based
- IEnumerable (Properties, Content, Elements)
- String (Properties, Content, RegExp )
- Numeric Type(Properties, Comparisons, Floating)
- Dictionary
- Char (Properties, Value)
- IComparable
- DateTime
- DateTimeOffset
- Misc: Boolean, TimeSpan, Stream, Enum, EventWaitHandle
- Check.ThatCode
- Check.ThatDynamic
- Extensibility
- Auxiliary types (TimeUnit)
- Mocks