mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 19:46:07 +00:00
20 lines
628 B
C#
20 lines
628 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using NSubstitute;
|
|
using NSubstitute.Core;
|
|
|
|
public static class NSubstituteExtensions
|
|
{
|
|
public static ConfiguredCall ReturnsAsync<TTask, TTaskType>(
|
|
this TTask value, Func<CallInfo, TTaskType> returnThis,
|
|
params Func<CallInfo, TTaskType>[] returnThese) where TTask : Task<TTaskType>
|
|
{
|
|
return value.Returns(callInfo => Task.FromResult(returnThis(callInfo)));
|
|
}
|
|
|
|
public static ConfiguredCall ThrowsAsync<T>(this Task<T> value, Exception exception)
|
|
{
|
|
return value.ReturnsAsync<Task<T>, T>(callInfo => { throw exception; });
|
|
}
|
|
}
|