tpierrain / NFluent

Smooth your .NET TDD experience with NFluent! NFluent is an ergonomic assertion library which aims to fluent your .NET TDD experience (based on simple Check.That() assertion statements). NFluent aims your tests to be fluent to write (with a super-duper-happy 'dot' auto-completion experience), fluent to read (i.e. as close as possible to plain English expression), but also fluent to troubleshoot, in a less-error-prone way comparing to the classical .NET test frameworks. NFluent is also directly inspired by the awesome Java FEST Fluent assertion/reflection library (http://fest.easytesting.org/)
Apache License 2.0
310 stars 53 forks source link

Fluent check any attribute/property on thrown exception #315

Closed dupdob closed 4 years ago

dupdob commented 4 years ago

As of V 2.6, NFluent offers to check if a bit of code throws an exception of a given type as well as the message of this exception and the type of inner exceptions (if any). But there is no way to check for an arbitrary attribute.

see https://stackoverflow.com/questions/58290516/nfluent-fluently-check-a-property-of-an-exception

Expected Behavior

Check.ThatCode(() => somefunction("qux", 1, null))
     .Throws<FooException>()
     .«WhatDoIPutHere»
     .IsInAscendingOrder();

Current Behavior

Not supported. One needs to capture the exception through try...catch and then check it.