public void Test_OpenConnection() { //---------------Set up test pack------------------- DatabaseConnection conn = new DatabaseConnectionSQLite("System.Data.SQLite", "System.Data.SQLite.SQLiteConnection"); conn.ConnectionString = new DatabaseConfig(DatabaseConfig.SQLite, "", "sqlite-testdb.db", "", "", "").GetConnectionString(); //---------------Execute Test ---------------------- IDbConnection openConnection = null; try { openConnection = conn.GetOpenConnectionForReading(); //---------------Test Result ----------------------- Assert.IsNotNull(openConnection); Assert.AreEqual(ConnectionState.Open, openConnection.State ); Assert.AreEqual("System.Data.SQLite", openConnection.GetType().Namespace); } //---------------Tear down ------------------------- finally { if (openConnection != null && openConnection.State != ConnectionState.Closed) { openConnection.Close();} } }
public void Test_BeginTransaction() { //---------------Set up test pack------------------- DatabaseConnection conn = new DatabaseConnectionSQLite("System.Data.SQLite", "System.Data.SQLite.SQLiteConnection"); conn.ConnectionString = new DatabaseConfig(DatabaseConfig.SQLite, "", "sqlite-testdb.db", "", "", "").GetConnectionString(); //---------------Execute Test ---------------------- IDbConnection openConnection = null; try { openConnection = conn.GetOpenConnectionForReading(); IDbTransaction transaction = conn.BeginTransaction(openConnection); //---------------Test Result ----------------------- Assert.IsNotNull(transaction); Assert.AreSame(openConnection, transaction.Connection); Assert.AreEqual(IsolationLevel.Serializable, transaction.IsolationLevel); } //---------------Tear down ------------------------- finally { if (openConnection != null && openConnection.State != ConnectionState.Closed) { openConnection.Close(); } } }