File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
projects/Test/Integration Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,43 @@ public async Task TestConsumerDispatcherShutdown()
64
64
Assert . True ( autorecoveringChannel . ConsumerDispatcher . IsShutdown , "dispatcher should be shut down after CloseAsync" ) ;
65
65
}
66
66
67
+ [ Fact ]
68
+ public async Task TestChannelClose ( )
69
+ {
70
+ var tcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
71
+
72
+ _channel . ChannelShutdownAsync += ( channel , args ) =>
73
+ {
74
+ tcs . SetResult ( true ) ;
75
+ return Task . CompletedTask ;
76
+ } ;
77
+
78
+ await _channel . CloseAsync ( ) ;
79
+ await WaitAsync ( tcs , TimeSpan . FromSeconds ( 5 ) , "channel shutdown" ) ;
80
+ }
81
+
82
+ [ Fact ]
83
+ public async Task TestChannelCloseWithCancellation ( )
84
+ {
85
+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 2 ) ) ;
86
+ var tcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
87
+
88
+ _channel . ChannelShutdownAsync += async ( channel , args ) =>
89
+ {
90
+ try
91
+ {
92
+ await Task . Delay ( TimeSpan . FromMinutes ( 1 ) , args . CancellationToken ) ;
93
+ }
94
+ catch ( OperationCanceledException )
95
+ {
96
+ tcs . SetResult ( true ) ;
97
+ }
98
+ } ;
99
+
100
+ await _channel . CloseAsync ( cts . Token ) ;
101
+ await WaitAsync ( tcs , TimeSpan . FromSeconds ( 5 ) , "channel shutdown" ) ;
102
+ }
103
+
67
104
[ Fact ]
68
105
public async Task TestConcurrentDisposeAsync_GH1749 ( )
69
106
{
You can’t perform that action at this time.
0 commit comments