コード例 #1
0
 public void Test_IsolationLevel_SQLite()
 {
     //---------------Execute Test ----------------------
     DatabaseConnection conn =
         new DatabaseConnectionSQLite("System.Data.SQLite", "System.Data.SQLite.SQLiteConnection");
     //---------------Test Result -----------------------
     Assert.AreEqual(IsolationLevel.Serializable, conn.IsolationLevel);
 }
コード例 #2
0
 public void Test_CreateDatabaseConnection_SQLite()
 {
     DatabaseConnection conn =
         new DatabaseConnectionSQLite("System.Data.SQLite", "System.Data.SQLite.SQLiteConnection");
     conn.ConnectionString =
         new DatabaseConfig(DatabaseConfig.SQLite, "test", "test", "test", "test", "1000").GetConnectionString();
     Assert.AreEqual("System.Data.SQLite", conn.TestConnection.GetType().Namespace,
                     "Namespace of SQLite connection is wrong.");
 }
コード例 #3
0
 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();}
     }
 }
コード例 #4
0
        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(); }
            }

        }
コード例 #5
0
 public void TestCreateParameterNameGenerator()
 {
     //---------------Set up test pack-------------------
     IDatabaseConnection databaseConnection = new DatabaseConnectionSQLite("", "");
     //---------------Assert PreConditions---------------            
     //---------------Execute Test ----------------------
     IParameterNameGenerator generator = databaseConnection.CreateParameterNameGenerator();
     //---------------Test Result -----------------------
     Assert.AreEqual(":", generator.PrefixCharacter);
     //---------------Tear Down -------------------------          
 }
コード例 #6
0
 public void Test_CreateSqlFormatter_AlternateConstructor_SQLite()
 {
     //---------------Set up test pack-------------------
     string connectionString =
         new DatabaseConfig(DatabaseConfig.SqlServer, "test", "test", "test", "test", "1000").GetConnectionString
             ();
     IDatabaseConnection dbConn = new DatabaseConnectionSQLite
         ("System.Data", "System.Data.SqlClient.SqlConnection", connectionString);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     ISqlFormatter defaultSqlFormatter = dbConn.SqlFormatter;
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(SqlFormatter), defaultSqlFormatter);
     SqlFormatter sqlFormatter = (SqlFormatter)defaultSqlFormatter;
     Assert.IsNotNull(sqlFormatter);
     Assert.AreEqual("\"", sqlFormatter.LeftFieldDelimiter);
     Assert.AreEqual("\"", sqlFormatter.RightFieldDelimiter);
     Assert.AreEqual("", sqlFormatter.LimitClauseAtBeginning);
     Assert.AreEqual("limit", sqlFormatter.LimitClauseAtEnd);
     Assert.AreEqual(sqlFormatter.LeftFieldDelimiter, dbConn.LeftFieldDelimiter);
     Assert.AreEqual(sqlFormatter.RightFieldDelimiter, dbConn.RightFieldDelimiter);
     //            StringAssert.Contains(sqlFormatter.LimitClauseAtBeginning, dbConn.GetLimitClauseForBeginning(1));
     //            StringAssert.Contains(sqlFormatter.LimitClauseAtEnd, dbConn.GetLimitClauseForEnd(1));
 }