-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Background
I can do this:
action.Should().Throw<TargetInvocationException>()
.WithInnerExceptionExactly<TException>() // <--- known at compile time
.Where(x => x.Message == message)
.And.ParamName.Should().Be(paramName);Problem
The above assumes I know TException at compile time. But what if I don't?
I can rewrite it using a trick I learnt from @dennisdoomen, like this:
action.Should().Throw<TargetInvocationException>()
.WithInnerException<Exception>().Which.Should().BeOfType(expectedType)
//.Where(x => x.Message == message)
//.And.ParamName.Should().Be(paramName);But then I can't chain .Where etc.
Feature Request
I read the exception docs but couldn't find a workaround.
Please consider adding an overload that take an instance:
.WithInnerExceptionExactly(expectedType)Versions
- Which version of Fluent Assertions are you using? 5.10.3
- Which .NET runtime and version are you targeting? 5.0.301