File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -225,4 +225,20 @@ public static void ResultToDelegate()
225225 private static TResult FromError < TError , TResult > ( TError error )
226226 where TResult : struct , IResultMonad < int , TError , TResult >
227227 => TResult . FromError ( error ) ;
228+
229+ [ Fact ]
230+ public static async Task ConvertToTask ( )
231+ {
232+ Result < int > result = 42 ;
233+ var task = ( Task < int > ) result ;
234+ Equal ( 42 , await task ) ;
235+
236+ result = Result . FromException < int > ( new OperationCanceledException ( new CancellationToken ( canceled : true ) ) ) ;
237+ task = ( Task < int > ) result ;
238+ True ( task . IsCanceled ) ;
239+
240+ result = Result . FromException < int > ( new Exception ( ) ) ;
241+ task = ( Task < int > ) result ;
242+ await ThrowsAsync < Exception > ( Func . Constant ( task ) ) ;
243+ }
228244}
You can’t perform that action at this time.
0 commit comments