public void TestToStringOutputWithDefaultServerPort()
        {
            var builder = new MongoConnectionStringBuilder();

            builder.AddServer("testserver");
            Assert.AreEqual("Server=testserver", builder.ToString());
        }
        public void TestToStringOutputWithoutUsernameAndPassword()
        {
            var builder = new MongoConnectionStringBuilder();

            builder.AddServer("testserver", 555);

            Assert.AreEqual("Server=testserver:555", builder.ToString());
        }
 public void TestServerCirculationWorks()
 {
     var builder = new MongoConnectionStringBuilder();
     builder.AddServer("localhost", 27017);
     builder.AddServer("localhost", 27018);
     using(var pool = new PooledConnectionFactory(builder.ToString()))
     {
         var connection1 = pool.Open();
         var connection2 = pool.Open();
         var connection3 = pool.Open();
         var connection4 = pool.Open();
         var connection5 = pool.Open();
         Assert.AreEqual(27017, connection1.EndPoint.Port);
         Assert.AreEqual(27018, connection2.EndPoint.Port);
         Assert.AreEqual(27017, connection3.EndPoint.Port);
         Assert.AreEqual(27018, connection4.EndPoint.Port);
         Assert.AreEqual(27017, connection5.EndPoint.Port);
     }
 }
        public void TestToStringOutput()
        {
            var builder = new MongoConnectionStringBuilder
            {
                Password           = "******",
                Username           = "******",
                ConnectionLifetime = TimeSpan.FromSeconds(50),
                MaximumPoolSize    = 101,
                MinimumPoolSize    = 202,
                ConnectionTimeout  = TimeSpan.FromSeconds(60)
            };

            builder.AddServer("testserver1", 555);
            builder.AddServer("testserver2");

            Assert.AreEqual(
                "Username=testusername;Password=testpassword;Server=testserver1:555,testserver2;MaximumPoolSize=101;MinimumPoolSize=202;ConnectionTimeout=60;ConnectionLifetime=50",
                builder.ToString());
        }
Пример #5
0
        public void TestServerCirculationWorks()
        {
            var builder = new MongoConnectionStringBuilder();

            builder.AddServer("localhost", 27017);
            builder.AddServer("localhost", 27018);
            using (var pool = new PooledConnectionFactory(builder.ToString()))
            {
                var connection1 = pool.Open();
                var connection2 = pool.Open();
                var connection3 = pool.Open();
                var connection4 = pool.Open();
                var connection5 = pool.Open();
                Assert.AreEqual(27017, connection1.EndPoint.Port);
                Assert.AreEqual(27018, connection2.EndPoint.Port);
                Assert.AreEqual(27017, connection3.EndPoint.Port);
                Assert.AreEqual(27018, connection4.EndPoint.Port);
                Assert.AreEqual(27017, connection5.EndPoint.Port);
            }
        }
        public void TestToStringOutput(){
            var builder = new MongoConnectionStringBuilder
            {
                Password = "******",
                Username = "******",
                ConnectionLifetime = TimeSpan.FromSeconds(50),
                MaximumPoolSize = 101,
                MinimumPoolSize = 202,
                ConnectionTimeout = TimeSpan.FromSeconds(60)
            };
            builder.AddServer("testserver1", 555);
            builder.AddServer("testserver2");

            Assert.AreEqual(
                "Username=testusername;Password=testpassword;Server=testserver1:555,testserver2;MaximumPoolSize=101;MinimumPoolSize=202;ConnectionTimeout=60;ConnectionLifetime=50",
                builder.ToString());
        }
        public void TestToStringOutputWithoutUsernameAndPassword(){
            var builder = new MongoConnectionStringBuilder();
            builder.AddServer("testserver", 555);

            Assert.AreEqual("Server=testserver:555", builder.ToString());
        }
 public void TestToStringOutputWithDefaultServerPort(){
     var builder = new MongoConnectionStringBuilder();
     builder.AddServer("testserver");
     Assert.AreEqual("Server=testserver", builder.ToString());
 }