So I tried copying an example about exception throwing from the documentation, and added this to one of my methods:
.Returns( x => { throw new Exception(); });
But this results in the following compiler error:
Error CS0121 The call is ambiguous between the following methods or properties: 'SubstituteExtensions.Returns(T, Func, params Func[])' and 'SubstituteExtensions.Returns(Task, Func, params Func[])'
The method I'm using is an async method. I tried awaiting the method first, but that returns a different error, saying that it
can not return value of type X for (expected type Task`1)
UPDATE: I can change the lambda in the returns to be async as a way to get around the compiler error, but this results in a warning. So I guess the question now is more about whether or not there's a way to bypass this without having the warning show up, and without adding needless await code inside the lambda itself?
Is there a way to avoid this? I'm using NSubstitute 2.0.3
Thank you for any help.