@@ -56,7 +56,8 @@ public async Task InitializeAsync()
5656        { 
5757            _connFactory  =  CreateConnectionFactory ( ) ; 
5858            _connFactory . DispatchConsumersAsync  =  true ; 
59-             _conn  =  _connFactory . CreateConnection ( ) ; 
59+             _conn  =  await  _connFactory . CreateConnectionAsync ( ) ; 
60+             Assert . IsType < RabbitMQ . Client . Framing . Impl . AutorecoveringConnection > ( _conn ) ; 
6061            _channel  =  await  _conn . CreateChannelAsync ( ) ; 
6162        } 
6263
@@ -118,22 +119,23 @@ await TestExceptionHandlingWith(consumer, (ch, q, c, ct) =>
118119        protected  async  Task  TestExceptionHandlingWith ( IBasicConsumer  consumer , 
119120            Func < IChannel ,  string ,  IBasicConsumer ,  string ,  ValueTask >  action ) 
120121        { 
121-             var  semaphore  =  new  SemaphoreSlim ( 0 ,  1 ) ; 
122-             bool  notified  =  false ; 
122+             var  waitSpan  =  TimeSpan . FromSeconds ( 2 ) ; 
123+             var  tcs  =  new  TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ; 
124+             var  cts  =  new  CancellationTokenSource ( waitSpan ) ; 
125+             cts . Token . Register ( ( )  =>  tcs . TrySetResult ( false ) ) ; 
126+ 
123127            string  q  =  await  _channel . QueueDeclareAsync ( string . Empty ,  false ,  false ,  true ,  false ,  null ) ; 
124128            _channel . CallbackException  +=  ( ch ,  evt )  => 
125129            { 
126130                if  ( evt . Exception  ==  TestException ) 
127131                { 
128-                     notified  =  true ; 
129-                     semaphore . Release ( ) ; 
132+                     tcs . SetResult ( true ) ; 
130133                } 
131134            } ; 
132135
133136            string  tag  =  await  _channel . BasicConsumeAsync ( q ,  true ,  string . Empty ,  false ,  false ,  null ,  consumer ) ; 
134137            await  action ( _channel ,  q ,  consumer ,  tag ) ; 
135-             Assert . True ( await  semaphore . WaitAsync ( TimeSpan . FromSeconds ( 2 ) ) ) ; 
136-             Assert . True ( notified ) ; 
138+             Assert . True ( await  tcs . Task ) ; 
137139        } 
138140
139141        private  class  ConsumerFailingOnDelivery  :  AsyncEventingBasicConsumer 
0 commit comments