Burrow.Tests.Internal.ManagedConnectionFactoryTests.MethodCreateConnection.Should_clear_existing_connection_from_shared_connection_list_if_connection_is_dropped_by_peer C# (CSharp) Метод

Should_clear_existing_connection_from_shared_connection_list_if_connection_is_dropped_by_peer() приватный Метод

        public void Should_clear_existing_connection_from_shared_connection_list_if_connection_is_dropped_by_peer()
        {
            ManagedConnectionFactory.SharedConnections.Clear();
            var connection = Substitute.For<IConnection>();
            connection.IsOpen.Returns(true);
            
            var factory = Substitute.For<ManagedConnectionFactory>();
            factory.HostName = "localhost";
            factory.VirtualHost = "/virtualhost";
            factory.EstablishConnection().Returns(connection);

            // Action
            factory.CreateConnection();
            Assert.AreEqual(1, ManagedConnectionFactory.SharedConnections.Count);
            connection.ConnectionShutdown += Raise.EventWith(connection, new ShutdownEventArgs(ShutdownInitiator.Application, 0, "Connection dropped for unknow reason ;)"));
            // Assert
            Assert.AreEqual(0, ManagedConnectionFactory.SharedConnections.Count);
        }