PublicTryReconnect() public method

public PublicTryReconnect ( IModel disconnectedChannel, System.Guid id, RabbitMQ.Client.ShutdownEventArgs eventArgs ) : void
disconnectedChannel IModel
id System.Guid
eventArgs RabbitMQ.Client.ShutdownEventArgs
return void
コード例 #1
0
        public void Should_reconnect_if_user_ack_wrong_delivery_id()
        {
            // Arrange
            var waitHandler = new AutoResetEvent(false);
            var id          = Guid.NewGuid();
            var channel     = Substitute.For <IModel>();

            channel.IsOpen.Returns(true);
            var routeFinder       = Substitute.For <IRouteFinder>();
            var durableConnection = Substitute.For <IDurableConnection>();

            //durableConnection.ConnectionFactory.Returns(Substitute.For<ConnectionFactory>());
            durableConnection.When(x => x.Connect()).Do(callInfo =>
            {
                durableConnection.Connected += Raise.Event <Action>();
                durableConnection.IsConnected.Returns(true);
            });

            durableConnection.CreateChannel().Returns(channel);
            var    tunnel = new RabbitTunnelForTest(routeFinder, durableConnection);
            Action action = () => waitHandler.Set();

            tunnel.SubscribeActions[id] = action;
            tunnel.CreatedChannels.Add(channel);


            // Action
            tunnel.PublicTryReconnect(channel, id, new ShutdownEventArgs(ShutdownInitiator.Peer, 406, "PRECONDITION_FAILED - unknown delivery tag 10000"));
            waitHandler.WaitOne(5000);

            // Assert
            Assert.IsTrue(tunnel.CreatedChannels.Count == 0);
        }
コード例 #2
0
        public void Should_reconnect_if_user_ack_wrong_delivery_id()
        {
            // Arrange
            var waitHandler = new AutoResetEvent(false);
            var id = Guid.NewGuid();
            var channel = Substitute.For<IModel>();
            channel.IsOpen.Returns(true);
            var routeFinder = Substitute.For<IRouteFinder>();
            var durableConnection = Substitute.For<IDurableConnection>();
            durableConnection.ConnectionFactory.Returns(Substitute.For<ConnectionFactory>());
            durableConnection.When(x => x.Connect()).Do(callInfo =>
            {
                durableConnection.Connected += Raise.Event<Action>();
                durableConnection.IsConnected.Returns(true);
            });

            durableConnection.CreateChannel().Returns(channel);
            var tunnel = new RabbitTunnelForTest(routeFinder, durableConnection);
            Action action = () => waitHandler.Set();
            tunnel.SubscribeActions[id] = action;
            tunnel.CreatedChannels.Add(channel);
            

            // Action
            tunnel.PublicTryReconnect(channel, id, new ShutdownEventArgs(ShutdownInitiator.Peer, 406, "PRECONDITION_FAILED - unknown delivery tag 10000"));
            waitHandler.WaitOne(5000);

            // Assert
            Assert.IsTrue(tunnel.CreatedChannels.Count == 0);
            
        }