Exemple #1
0
        public void Test_All_Connections_Are_Authenticated_After_Initialize()
        {
            var pool = new SharedConnectionPool <IConnection>(new PoolConfiguration {
                MaxSize = 5
            }, new IPEndPoint(0, 10210), _factory, new DefaultConverter());

            var saslMechanism = new Mock <ISaslMechanism>();

            saslMechanism.Setup(x => x.Authenticate(It.IsAny <IConnection>())).Returns(true);
            pool.SaslMechanism = saslMechanism.Object;

            pool.Initialize();

            Assert.IsTrue(pool.Connections.Any(x => x.IsAuthenticated));
        }
Exemple #2
0
        public void TestAcquire()
        {
            var pool = new SharedConnectionPool <IConnection>(new PoolConfiguration(), new IPEndPoint(0, 10210), _factory, new DefaultConverter());

            var threads = new List <Thread>(10);

            for (var i = 0; i < 10; i++)
            {
                threads.Add(new Thread(DoWork));
            }
            foreach (var thread in threads)
            {
                thread.Start(pool);
            }
            foreach (var thread in threads)
            {
                thread.Join();
            }
            Assert.IsFalse(Failed);
        }