Skip to content

Simple expectations

Davyd McColl edited this page Oct 14, 2017 · 2 revisions

The simplest checks are probably:

Null

Expect(foo).To.Be.Null();
Expect(foo).Not.To.Be.Null();
Expect(foo).To.Not.Be.Null();

Further documentation will omit the negations -- they should become obvious.

Equality

Expect(foo).To.Equal(bar);
Expect(foo).To.Be.Equal.To(bar);

Note that NExpect is strongly typed -- starting an Expectation on foo expects a comparison with a value of the same type. Expected implicit upcasts are catered for so that you can easily perform expectations with different numeric types:

Expect(intValue).To.Equal(longValue);
Expect(longValue).To.Equal(decimalValue);
Expect(decimalValue).To.Equal(intValue);

(A future feature is to allow comparison with minor variance, most especially for floating-point numbers. If this is important to you, raise an issue! User interaction with the project is welcome!)