Esempio n. 1
0
        public void CloseConnections()
        {
            SqlCeConnectionPool.CloseSharedConnections();
            TestConnectionString testConnection = new TestConnectionString();

            testConnection.DeleteFile();
        }
        public void TearDown()
        {
            SqlCeConnectionPool.CloseSharedConnections();
            TestConnectionString test = new TestConnectionString();

            test.DeleteFile();
        }
 public void TestCleanup()
 {
     deleteCommand.Dispose();
     insertCommand.Dispose();
     updateCommand.Dispose();
     base.TearDown();
     SqlCeConnectionPool.CloseSharedConnections();
     testConnection.DeleteFile();
 }
Esempio n. 4
0
        public void CloseSharedConnectionsShouldClearPool()
        {
            TestConnectionString testConnection = new TestConnectionString();
            SqlCeDatabase        db             = new SqlCeDatabase(testConnection.ConnectionString);

            using (DbConnection connection = SqlCeConnectionPool.CreateConnection(db)) {}
            Assert.AreEqual(1, TestableSqlCeConnectionPool.PoolSize);
            SqlCeConnectionPool.CloseSharedConnections();
            Assert.AreEqual(0, TestableSqlCeConnectionPool.PoolSize);
        }
        public void ExecuteResultSet_ShouldCloseConnection()
        {
            DbConnection connection;

            using (DbCommand command = db.GetSqlStringCommand(queryString))
            {
                using (SqlCeResultSet reader = db.ExecuteResultSet(command))
                {
                    connection = command.Connection;
                }

                // Force shared pool closed, this should close out shared connection used by the reader.
                SqlCeConnectionPool.CloseSharedConnections();
                Assert.AreEqual(ConnectionState.Closed, connection.State);
            }
        }
        public void ExecuteResultSetWithBadCommandThrowsAndClosesConnection()
        {
            DbCommand badCommand = db.GetSqlStringCommand("select * from invalid");

            try
            {
                db.ExecuteResultSet(badCommand);
            }
            catch (SqlCeException)
            {
            }

            Assert.IsNotNull(badCommand.Connection); // Held open by pool
            // Force shared connection closed
            SqlCeConnectionPool.CloseSharedConnections();
            Assert.IsNull(badCommand.Connection);
        }
Esempio n. 7
0
        public void GetConnectionForTwoFilesAddsTwoConnectionsToPool()
        {
            TestConnectionString file1 = new TestConnectionString();
            TestConnectionString file2 = new TestConnectionString("test2.sdf");

            file2.CopyFile();
            SqlCeDatabase db1 = new SqlCeDatabase(file1.ConnectionString);
            SqlCeDatabase db2 = new SqlCeDatabase(file2.ConnectionString);

            using (DbConnection connection1 = SqlCeConnectionPool.CreateConnection(db1))
            {
                using (DbConnection connection2 = SqlCeConnectionPool.CreateConnection(db2)) {}
            }
            Assert.AreEqual(2, TestableSqlCeConnectionPool.PoolSize);
            SqlCeConnectionPool.CloseSharedConnections();
            file2.DeleteFile();
        }
 public void TearDown()
 {
     SqlCeConnectionPool.CloseSharedConnections();
 }
Esempio n. 9
0
 public void DeleteDb()
 {
     SqlCeConnectionPool.CloseSharedConnections();
     testConnection.DeleteFile();
 }