File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public static AwaitAdapter Create(ValueTask task)
2727 return null ;
2828 }
2929
30- private sealed class NonGenericAdapter : AwaitAdapter
30+ private sealed class NonGenericAdapter : DefaultBlockingAwaitAdapter
3131 {
3232 private readonly ValueTaskAwaiter _awaiter ;
3333
@@ -40,17 +40,14 @@ public NonGenericAdapter(ValueTask task)
4040
4141 public override void OnCompleted ( Action action ) => _awaiter . UnsafeOnCompleted ( action ) ;
4242
43- // Assumption that GetResult blocks until complete is only valid for System.Threading.Tasks.ValueTask.
44- public override void BlockUntilCompleted ( ) => _awaiter . GetResult ( ) ;
45-
4643 public override object ? GetResult ( )
4744 {
4845 _awaiter . GetResult ( ) ; // Throws exceptions, if any
4946 return null ;
5047 }
5148 }
5249
53- private sealed class GenericAdapter < T > : AwaitAdapter
50+ private sealed class GenericAdapter < T > : DefaultBlockingAwaitAdapter
5451 {
5552 private readonly ValueTaskAwaiter < T > _awaiter ;
5653
@@ -63,9 +60,6 @@ public GenericAdapter(ValueTask<T> task)
6360
6461 public override void OnCompleted ( Action action ) => _awaiter . UnsafeOnCompleted ( action ) ;
6562
66- // Assumption that GetResult blocks until complete is only valid for System.Threading.Tasks.ValueTask.
67- public override void BlockUntilCompleted ( ) => _awaiter . GetResult ( ) ;
68-
6963 public override object ? GetResult ( )
7064 {
7165 return _awaiter . GetResult ( ) ; // Throws exceptions, if any
Original file line number Diff line number Diff line change @@ -741,6 +741,21 @@ private static IEnumerable ExceptionSource
741741 }
742742 }
743743 #endregion
744+
745+ [ TestCaseSource ( nameof ( AsyncEnumerableTestCases ) ) ]
746+ public async Task TestAsyncEnumerable ( int expected , int actual )
747+ {
748+ await Task . Delay ( 100 ) ; // Simulate an asynchronous operation
749+ Assert . That ( actual , Is . EqualTo ( expected ) ) ;
750+ }
751+
752+ private static async IAsyncEnumerable < TestCaseData > AsyncEnumerableTestCases ( )
753+ {
754+ await Task . Delay ( 100 ) ; // Simulate an asynchronous operation
755+ yield return new TestCaseData ( 42 , 42 ) ;
756+ await Task . Delay ( 100 ) ; // Simulate another asynchronous operation
757+ yield return new TestCaseData ( 51 , 51 ) ;
758+ }
744759 }
745760
746761 public class TestSourceMayBeInherited
You can’t perform that action at this time.
0 commit comments