Created
December 24, 2012 00:56
-
-
Save JakeGinnivan/4366936 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void ReturnsValueAsTask<T>(this Task<T> value, T returnThis, params T[] returnThese) | |
| { | |
| Returns(MatchArgs.AsSpecifiedInCall, ToCompletedTask(returnThis), returnThese.Select(ToCompletedTask).ToArray()); | |
| } | |
| public static void ReturnsValueAsTask<T>(this Task<T> value, Func<CallInfo, T> returnThis) | |
| { | |
| Returns(MatchArgs.AsSpecifiedInCall, c => ToCompletedTask(returnThis(c))); | |
| } | |
| private static Task<T> ToCompletedTask<T>(T value) | |
| { | |
| var taskCompletionSource = new TaskCompletionSource<T>(); | |
| taskCompletionSource.SetResult(value); | |
| return taskCompletionSource.Task; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jake.
Do you have examples how these extensions can be called?