@@ -228,21 +228,24 @@ public async Task TestTopologyRecoveryBindingFilter()
228
228
[ Fact ]
229
229
public async Task TestTopologyRecoveryDefaultFilterRecoversAllEntities ( )
230
230
{
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
+
231
237
var connectionRecoveryTcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
232
238
var filter = new TopologyRecoveryFilter ( ) ;
233
239
AutorecoveringConnection conn = await CreateAutorecoveringConnectionWithTopologyRecoveryFilterAsync ( filter ) ;
234
240
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
+
235
244
IChannel ch = await conn . CreateChannelAsync ( ) ;
236
245
try
237
246
{
238
247
await ch . ConfirmSelectAsync ( ) ;
239
248
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
-
246
249
await ch . ExchangeDeclareAsync ( exchange , "direct" ) ;
247
250
await ch . QueueDeclareAsync ( queue1 , false , false , false ) ;
248
251
await ch . QueueDeclareAsync ( queue2 , false , false , false ) ;
@@ -281,16 +284,14 @@ public async Task TestTopologyRecoveryDefaultFilterRecoversAllEntities()
281
284
await ch . QueueDeclarePassiveAsync ( queue1 ) ;
282
285
await ch . QueueDeclarePassiveAsync ( queue2 ) ;
283
286
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 ) ;
289
291
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 ) ;
294
295
}
295
296
finally
296
297
{
0 commit comments