File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
projects/client/Unit/src/unit Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -180,28 +180,38 @@ public void TestChannelShutdownDoesNotShutDownDispatcher()
180
180
private class ShutdownLatchConsumer : DefaultBasicConsumer
181
181
{
182
182
public ManualResetEvent Latch { get ; private set ; }
183
+ public ManualResetEvent LatchDuplicate { get ; private set ; }
183
184
184
- public ShutdownLatchConsumer ( ManualResetEvent latch )
185
+ public ShutdownLatchConsumer ( ManualResetEvent latch , ManualResetEvent latchDuplicate )
185
186
{
186
187
this . Latch = latch ;
188
+ this . LatchDuplicate = latchDuplicate ;
187
189
}
188
190
189
191
public override void HandleModelShutdown ( object model , ShutdownEventArgs reason )
190
192
{
191
- this . Latch . Set ( ) ;
193
+ // If Latch is already set - event is duplicate
194
+ if ( this . Latch . WaitOne ( 0 ) ) {
195
+ this . LatchDuplicate . Set ( ) ;
196
+ } else {
197
+ this . Latch . Set ( ) ;
198
+ }
192
199
}
193
200
}
194
201
195
202
[ Test ]
196
203
public void TestModelShutdownHandler ( )
197
204
{
198
205
var latch = new ManualResetEvent ( false ) ;
206
+ var latchDuplicate = new ManualResetEvent ( false ) ;
199
207
var q = this . Model . QueueDeclare ( ) . QueueName ;
200
- var c = new ShutdownLatchConsumer ( latch ) ;
208
+ var c = new ShutdownLatchConsumer ( latch , latchDuplicate ) ;
201
209
202
210
this . Model . BasicConsume ( queue : q , noAck : true , consumer : c ) ;
203
211
this . Model . Close ( ) ;
204
212
Wait ( latch , TimeSpan . FromSeconds ( 5 ) ) ;
213
+ Assert . IsFalse ( latchDuplicate . WaitOne ( TimeSpan . FromSeconds ( 5 ) ) ,
214
+ "duplicate events" ) ;
205
215
}
206
216
}
207
217
}
You can’t perform that action at this time.
0 commit comments