I have something like the following:
public class FooWrapper
{
public Action Foo { get; set; }
public void Execute()
{
try
{
Foo.Invoke();
}
catch (Exception exception)
{
//exception is null
//do something interesting with the exception
}
}
}
When I run my unit test with something like the following:
new FooWrapper() { Foo = () => { throw new Exception("test"); } };
The exception is thrown as expected but and the catch steps through but "exception" is null. How do I get to the exception thrown by an .Invoke() to properly handle it?