خرید بک لینک

Vote count: 0

Using NSubstitute, how do you mock an exception being thrown in a method retuing a Task?

Let's say our method sig looks something like this:

Task<List<object>> GetAllAsync();

Here's how NSubstitute docs say to mock throwing exceptions for non-void retu types. But this doesn't compile :(

myService.GetAllAsync().Retus(x => { throw new Exception(); });

So how do you accomplish this?

asked 8 secs ago

1 Answer

Vote count: 0

This worked:

using NSubstitute.ExceptionExtensions;

myService.GetAllAsync().Throws(new Exception());

answered 8 secs ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 23 تير 1395 ساعت: 4:22

صفحه بندی