コード例 #1
0
 private static void CleanTables()
 {
     using (var connection = ConnectionUtils.CreateConnection())
     {
         PostgreSqlTestObjectsInitializer.CleanTables(connection);
     }
 }
コード例 #2
0
        private static void RecreateSchemaAndInstallObjects()
        {
            using (var connection = ConnectionUtils.CreateMasterConnection())
            {
                bool databaseExists = connection.Query <bool?>(
                    @"select true :: boolean from pg_database where datname = @databaseName;",
                    new
                {
                    databaseName = ConnectionUtils.GetDatabaseName()
                }
                    ).SingleOrDefault() ?? false;

                if (!databaseExists)
                {
                    connection.Execute($@"CREATE DATABASE ""{ConnectionUtils.GetDatabaseName()}""");
                }
            }

            using (var connection = ConnectionUtils.CreateConnection())
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }

                PostgreSqlObjectsInstaller.Install(connection);
                PostgreSqlTestObjectsInitializer.CleanTables(connection);
            }
        }
コード例 #3
0
        private static void RecreateSchemaAndInstallObjects()
        {
            using (var connection = new NpgsqlConnection(
                       ConnectionUtils.GetMasterConnectionString()))
            {
                bool databaseExists = connection.Query <bool?>(
                    @"select true :: boolean from pg_database where datname = @databaseName;",
                    new
                {
                    databaseName = ConnectionUtils.GetDatabaseName()
                }
                    ).SingleOrDefault() ?? false;

                if (!databaseExists)
                {
                    connection.Execute(String.Format(@"CREATE DATABASE ""{0}""", ConnectionUtils.GetDatabaseName()));
                }
            }

            using (var connection = new NpgsqlConnection(
                       ConnectionUtils.GetConnectionString()))
            {
                PostgreSqlObjectsInstaller.Install(connection);
                PostgreSqlTestObjectsInitializer.CleanTables(connection);
            }
        }
コード例 #4
0
 private static void CleanTables()
 {
     using (var connection = new NpgsqlConnection(
                ConnectionUtils.GetConnectionString()))
     {
         PostgreSqlTestObjectsInitializer.CleanTables(connection);
     }
 }