@@ -29,6 +29,7 @@ public async Task TestConsumerCancellation()
2929 var tcsShutdownCancelled = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
3030
3131 var consumer = new AsyncEventingBasicConsumer ( _channel ) ;
32+
3233 consumer . ShutdownAsync += async ( model , ea ) =>
3334 {
3435 try
@@ -40,6 +41,7 @@ public async Task TestConsumerCancellation()
4041 tcsShutdownCancelled . SetResult ( true ) ;
4142 }
4243 } ;
44+
4345 consumer . ReceivedAsync += async ( model , ea ) =>
4446 {
4547 tcsMessageReceived . SetResult ( true ) ;
@@ -52,6 +54,7 @@ public async Task TestConsumerCancellation()
5254 tcsReceivedCancelled . SetResult ( true ) ;
5355 }
5456 } ;
57+
5558 await _channel . BasicConsumeAsync ( queueName , false , consumer ) ;
5659
5760 //publisher
@@ -65,8 +68,8 @@ await publisherChannel.BasicPublishAsync(exchange: exchangeName, routingKey: str
6568
6669 await _channel . CloseAsync ( ) ;
6770
68- await WaitAsync ( tcsMessageReceived , TimeSpan . FromSeconds ( 5 ) , "Consumer closed " ) ;
69- await WaitAsync ( tcsShutdownCancelled , TimeSpan . FromSeconds ( 5 ) , "Consumer closed " ) ;
71+ await WaitAsync ( tcsReceivedCancelled , TimeSpan . FromSeconds ( 5 ) , "ReceivedAsync cancelled " ) ;
72+ await WaitAsync ( tcsShutdownCancelled , TimeSpan . FromSeconds ( 5 ) , "ShutdownAsync cancellation " ) ;
7073 }
7174 }
7275}
0 commit comments