Repository navigation
NFluent's assertions structure
Cyrille DUPUYDAUBY edited this page Jan 31, 2018
·
7 revisions
- NFluent assertions are referred to as checks.
- An assertion can combine one or more checks using And or Which keywords.
- Writing an assertion To write an assertion you need to capture what needs to be evaluated (referred to as system under test or sut for short).
A few capturing methods are provided.
This is the most used one. You shoud use it by default and use a specialized one when needed. Example
var myItem = new Myclass();
...
Check.That(myItem).IsInstanceOf<MyClass>();This one must be used to test portion of code or a delegate. Example:
Check.ThatCode ( () =>
{
...
throw new ApplicationException();
}
).Throws<ApplicationException>();This one must be used to test asynchronous code/delegate lambda.
This one must be used to capture dynamics type, otherwise you will have compilation errors due to how dynamic types are implemented in .Net.
This one can be used on value types, such as structs or enums. While those types can be checked with Check.That, Check.ThatEnum offers some enum/struct specific checks.
- 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