@@ -228,21 +228,24 @@ public async Task TestTopologyRecoveryBindingFilter()
228228 [ Fact ]
229229 public async Task TestTopologyRecoveryDefaultFilterRecoversAllEntities ( )
230230 {
231+ const string exchange = "topology.recovery.exchange" ;
232+ const string queue1 = "topology.recovery.queue.1" ;
233+ const string queue2 = "topology.recovery.queue.2" ;
234+ const string binding1 = "recovered.binding" ;
235+ const string binding2 = "filtered.binding" ;
236+
231237 var connectionRecoveryTcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
232238 var filter = new TopologyRecoveryFilter ( ) ;
233239 AutorecoveringConnection conn = await CreateAutorecoveringConnectionWithTopologyRecoveryFilterAsync ( filter ) ;
234240 conn . RecoverySucceeded += ( source , ea ) => connectionRecoveryTcs . SetResult ( true ) ;
241+ conn . ConnectionRecoveryError += ( source , ea ) => connectionRecoveryTcs . SetException ( ea . Exception ) ;
242+ conn . CallbackException += ( source , ea ) => connectionRecoveryTcs . SetException ( ea . Exception ) ;
243+
235244 IChannel ch = await conn . CreateChannelAsync ( ) ;
236245 try
237246 {
238247 await ch . ConfirmSelectAsync ( ) ;
239248
240- string exchange = "topology.recovery.exchange" ;
241- string queue1 = "topology.recovery.queue.1" ;
242- string queue2 = "topology.recovery.queue.2" ;
243- string binding1 = "recovered.binding" ;
244- string binding2 = "filtered.binding" ;
245-
246249 await ch . ExchangeDeclareAsync ( exchange , "direct" ) ;
247250 await ch . QueueDeclareAsync ( queue1 , false , false , false ) ;
248251 await ch . QueueDeclareAsync ( queue2 , false , false , false ) ;
@@ -281,16 +284,14 @@ public async Task TestTopologyRecoveryDefaultFilterRecoversAllEntities()
281284 await ch . QueueDeclarePassiveAsync ( queue1 ) ;
282285 await ch . QueueDeclarePassiveAsync ( queue2 ) ;
283286
284- await ch . BasicPublishAsync ( exchange , binding1 , true , _encoding . GetBytes ( "test message" ) ) ;
285- // await ch.WaitForConfirmsOrDieAsync();
286-
287- await ch . BasicPublishAsync ( exchange , binding2 , true , _encoding . GetBytes ( "test message" ) ) ;
288- // await ch.WaitForConfirmsOrDieAsync();
287+ var pt1 = ch . BasicPublishAsync ( exchange , binding1 , true , _encoding . GetBytes ( "test message" ) ) ;
288+ var pt2 = ch . BasicPublishAsync ( exchange , binding2 , true , _encoding . GetBytes ( "test message" ) ) ;
289+ await WaitForConfirmsWithCancellationAsync ( ch ) ;
290+ await Task . WhenAll ( pt1 . AsTask ( ) , pt2 . AsTask ( ) ) . WaitAsync ( WaitSpan ) ;
289291
290- await consumerReceivedTcs1 . Task . WaitAsync ( TimeSpan . FromSeconds ( 5 ) ) ;
291- await consumerReceivedTcs2 . Task . WaitAsync ( TimeSpan . FromSeconds ( 5 ) ) ;
292- Assert . True ( consumerReceivedTcs1 . Task . IsCompletedSuccessfully ( ) ) ;
293- Assert . True ( consumerReceivedTcs2 . Task . IsCompletedSuccessfully ( ) ) ;
292+ await Task . WhenAll ( consumerReceivedTcs1 . Task , consumerReceivedTcs2 . Task ) . WaitAsync ( WaitSpan ) ;
293+ Assert . True ( await consumerReceivedTcs1 . Task ) ;
294+ Assert . True ( await consumerReceivedTcs2 . Task ) ;
294295 }
295296 finally
296297 {
0 commit comments