@@ -37,6 +37,24 @@ public async Task CreateConsumerAsync_ShouldDeriveQueueNameFromType()
3737 GetQueueName ( consumer ) . Should ( ) . Be ( "SimpleMessageQueue" ) ;
3838 }
3939
40+ [ Fact ]
41+ public async Task CreateConsumerAsync_ShouldForwardCancellationTokens ( )
42+ {
43+ var connectionShutdown = new ShutdownEventArgs ( ShutdownInitiator . Application , 200 , "closing" ) ;
44+ var channelShutdown = new ShutdownEventArgs ( ShutdownInitiator . Application , 200 , "channel closing" ) ;
45+ _connectionMock . Setup ( c => c . CloseReason ) . Returns ( connectionShutdown ) ;
46+ _channelMock . Setup ( c => c . CloseReason ) . Returns ( channelShutdown ) ;
47+ _connectionMock . Setup ( c => c . CreateChannelAsync ( options : null , connectionShutdown . CancellationToken ) )
48+ . ReturnsAsync ( _channelMock . Object ) ;
49+ _channelMock . Setup ( c => c . BasicQosAsync ( 0 , 1 , false , channelShutdown . CancellationToken ) )
50+ . Returns ( Task . CompletedTask ) ;
51+
52+ await using var _ = await _factory . CreateConsumerAsync < Messages . SimpleMessage > ( ) ;
53+
54+ _connectionMock . Verify ( c => c . CreateChannelAsync ( options : null , connectionShutdown . CancellationToken ) , Times . Once ) ;
55+ _channelMock . Verify ( c => c . BasicQosAsync ( 0 , 1 , false , channelShutdown . CancellationToken ) , Times . Once ) ;
56+ }
57+
4058 private static string GetQueueName ( RabbitMqConsumer < Messages . SimpleMessage > consumer ) =>
4159 ( string ) typeof ( RabbitMqConsumer < Messages . SimpleMessage > )
4260 . GetField ( "_queueName" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) !
0 commit comments