Beispiel #1
0
		public void LifeTimeIsTakenInAccount ()
		{
			var SMALLEST_LIFETIME_TO_TEST = 1;
			var WAIT_TO_MAKE_LIFETIME_PASSED = 2;

			TdsConnectionPoolManager sqlConnectionPools = new FakeConnectionPoolManager ();
			TdsConnectionInfo info = new TdsConnectionInfo ("dummy", 0, 0, 0,
			                                               1 /*minpoolsize*/,
			                                               1 /*maxpoolsize*/,
			                                               SMALLEST_LIFETIME_TO_TEST/*lifetime*/);

			TdsConnectionPool pool = sqlConnectionPools.GetConnectionPool ("test",info);
			Mono.Data.Tds.Protocol.Tds tds, tds2 = null;

			tds = pool.GetConnection();

			System.Threading.Thread.Sleep (TimeSpan.FromSeconds (WAIT_TO_MAKE_LIFETIME_PASSED));
			pool.ReleaseConnection (tds);

			tds2 = pool.GetConnection ();


			Assert.IsFalse (object.ReferenceEquals (tds, tds2));
			pool.ReleaseConnection(tds2);
		}
Beispiel #2
0
        public void LifeTimeIsTakenInAccount()
        {
            var SMALLEST_LIFETIME_TO_TEST    = 1;
            var WAIT_TO_MAKE_LIFETIME_PASSED = 2;

            TdsConnectionPoolManager sqlConnectionPools = new FakeConnectionPoolManager();
            TdsConnectionInfo        info = new TdsConnectionInfo("dummy", 0, 0, 0,
                                                                  1 /*minpoolsize*/,
                                                                  1 /*maxpoolsize*/,
                                                                  SMALLEST_LIFETIME_TO_TEST /*lifetime*/);

            TdsConnectionPool pool = sqlConnectionPools.GetConnectionPool("test", info);

            Mono.Data.Tds.Protocol.Tds tds, tds2 = null;

            tds = pool.GetConnection();

            System.Threading.Thread.Sleep(TimeSpan.FromSeconds(WAIT_TO_MAKE_LIFETIME_PASSED));
            pool.ReleaseConnection(tds);

            tds2 = pool.GetConnection();


            Assert.IsFalse(object.ReferenceEquals(tds, tds2));
            pool.ReleaseConnection(tds2);
        }