A super-class to manage a database connection and execute sql commands
Наследование: DatabaseConnection
 public void TestCreateParameterNameGenerator()
 {
     //---------------Set up test pack-------------------
     IDatabaseConnection databaseConnection = new DatabaseConnectionFirebird("", "");
     //---------------Assert PreConditions---------------            
     //---------------Execute Test ----------------------
     IParameterNameGenerator generator = databaseConnection.CreateParameterNameGenerator();
     //---------------Test Result -----------------------
     Assert.AreEqual("@", generator.PrefixCharacter);
     //---------------Tear Down -------------------------          
 }
        public void Test_CreateCustomConnectionString()
        {
            //---------------Set up test pack-------------------
            string connectString = "";
            DatabaseConnection databaseConnection = new DatabaseConnectionFirebird("", "", connectString);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string setConnectionString = databaseConnection.ConnectionString;

            //---------------Test Result -----------------------
            Assert.AreEqual(setConnectionString, connectString);
        }
        public void TestSqlFormatter()
        {
            //---------------Set up test pack-------------------
            DatabaseConnection databaseConnection = new DatabaseConnectionFirebird("", "");
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ISqlFormatter defaultSqlFormatter = databaseConnection.SqlFormatter;
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(SqlFormatter), defaultSqlFormatter);
            SqlFormatter formatter = (SqlFormatter)defaultSqlFormatter;
            Assert.AreEqual("", formatter.LeftFieldDelimiter);
            Assert.AreEqual("", formatter.RightFieldDelimiter);
            Assert.AreEqual("FIRST", formatter.LimitClauseAtBeginning);
            Assert.AreEqual("", formatter.LimitClauseAtEnd);

        }
Пример #4
0
        private static string CreateTemporaryFirebirdDatabase()
        {
            var databaseFile = Path.GetTempFileName();
            File.Delete(databaseFile);

            var conn = new DatabaseConnectionFirebird("FirebirdSql.Data.FirebirdClient", "FirebirdSql.Data.FirebirdClient.FbConnection");

            File.Delete(databaseFile);

            conn.ConnectionString = CreateFirebirdEmbeddedConnectionStringFor(databaseFile);
            TestUsingDatabase.WriteOutFirebirdEmbeddedLibrariesToCurrentDirectory();
            var concrete = conn.GetConnection();
            var creatorMethod = concrete.GetType().GetMethods().Where(mi =>
                                                                      {
                                                                          if (mi.Name != "CreateDatabase") return false;
                                                                          var parameters = mi.GetParameters();
                                                                          if (parameters.Length != 2) return false;
                                                                          if (parameters[0].Name != "connectionString") return false;
                                                                          if (parameters[0].ParameterType != typeof (string)) return false;
                                                                          if (parameters[1].Name != "overwrite") return false;
                                                                          if (parameters[1].ParameterType != typeof (bool)) return false;
                                                                          return true;
                                                                      }).FirstOrDefault();
            creatorMethod.Invoke(conn, new object[] {conn.ConnectionString, true});
            return databaseFile;
        }
        public void Test_CreateSqlFormatter_AlternateConstructor_Firebird()
        {
            //---------------Set up test pack-------------------
            string connectionString =
                new DatabaseConfig(DatabaseConfig.SqlServer, "test", "test", "test", "test", "1000").GetConnectionString
                    ();
            IDatabaseConnection dbConn = new DatabaseConnectionFirebird
                ("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("FIRST", sqlFormatter.LimitClauseAtBeginning);
            Assert.AreEqual("", 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));
        }
 public void Test_IsolationLevel_Firebird()
 {
     //---------------Execute Test ----------------------
     DatabaseConnection conn =
         new DatabaseConnectionFirebird("FirebirdSql.Data.FirebirdClient", "FirebirdSql.Data.FirebirdClient.FbConnection");
     //---------------Test Result -----------------------
     Assert.AreEqual(IsolationLevel.RepeatableRead, conn.IsolationLevel);
 }
 public void Test_CreateDatabaseConnection_Firebird()
 {
     
     DatabaseConnection conn = new DatabaseConnectionFirebird
         ("FirebirdSql.Data.FirebirdClient", "FirebirdSql.Data.FirebirdClient.FbConnection");
     conn.ConnectionString =
         new DatabaseConfig
             (DatabaseConfig.Firebird, "testserver", "testdatabase", "testusername", "testpassword", "3050").
             GetConnectionString();
     Assert.AreEqual
         ("FirebirdSql.Data.FirebirdClient", conn.TestConnection.GetType().Namespace,
          "Namespace of firebird connection is wrong.");
 }
 public void Test_CreateSqlFormatter_Firebird()
 {
     //---------------Set up test pack-------------------
     IDatabaseConnection dbConn = new DatabaseConnectionFirebird("System.Data", "System.Data.SqlClient.SqlConnection");
     //---------------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("FIRST", sqlFormatter.LimitClauseAtBeginning);
     Assert.AreEqual("", sqlFormatter.LimitClauseAtEnd);
     Assert.AreEqual(sqlFormatter.LeftFieldDelimiter, dbConn.LeftFieldDelimiter);
     Assert.AreEqual(sqlFormatter.RightFieldDelimiter, dbConn.RightFieldDelimiter);
 }