I have a function that is supposed to raise an exception FooException
. This exception has a list of items stored in one of its properties AffectedElements
. How can I perform tests against this list? For example:
Check.ThatCode(() => somefunction("qux", 1, null))
.Throws<FooException>()
.«WhatDoIPutHere»
.IsInAscendingOrder();
As of now, there is no way to extract a field/property from an exception to check it. The best you can do is use WithProperty which only support equality check:
Check.ThatCode(() => somefunction("qux", 1, null))
.Throws<FooException>()
.WithProperty("propName", expectedValue);
Update: The latest version of NFluent offers a feature for that. see the wiki
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With