コード例 #1
0
        public static JetTestStore CreateScratch(bool createDatabase)
        {
            string name;

            do
            {
                name = "scratch-" + Interlocked.Increment(ref _scratchCount);
            }while (File.Exists(name + ".accdb"));
            JetConnection.CreateEmptyDatabase(JetConnection.GetConnectionString(name + ".accdb"));
            return(new JetTestStore(name, deleteDatabase: true));
        }
コード例 #2
0
        public void CreateAndDropDatabaseFromConnection()
        {
            string dbFileName = "C:\\TEMP\\Test.accdb";

            File.Delete(dbFileName);

            var connection = new JetConnection(JetConnection.GetConnectionString(dbFileName));

            connection.CreateEmptyDatabase();
            var command = connection.CreateCommand();

            Assert.IsTrue(File.Exists(dbFileName));
            command.CommandText = "DROP DATABASE " + dbFileName;
            command.ExecuteNonQuery();
        }
コード例 #3
0
 public void Initialize()
 {
     if (!JetConnection.DatabaseExists(ConnectionString))
     {
         JetConnection.CreateEmptyDatabase(ConnectionString);
     }
     using (JetConnection connection = new JetConnection(ConnectionString))
     {
         connection.Open();
         if (!connection.TableExists("SimpleTable"))
         {
             connection.CreateCommand("CREATE TABLE SimpleTable ( Col varchar(10) )").ExecuteNonQuery();
         }
         connection.CreateCommand("DELETE FROM SimpleTable").ExecuteNonQuery();
     }
     JetConnection.ClearAllPools();
 }
コード例 #4
0
        private JetTestStore CreateTransient(bool createDatabase)
        {
            _connectionString = CreateConnectionString(_name);

            _connection = new JetConnection(_connectionString);

            if (createDatabase)
            {
                JetConnection.DropDatabase(_connectionString, false);
                _connection.CreateEmptyDatabase();
                _connection.Open();
            }

            _deleteDatabase = true;

            return(this);
        }
コード例 #5
0
        private bool CreateDatabase()
        {
            if (File.Exists(_name + ".accdb"))
            {
                if (_scriptPath != null)
                {
                    return(false);
                }

                using (var context = new DbContext(AddProviderOptions(new DbContextOptionsBuilder()).Options))
                {
                    Clean(context);
                    return(true);
                }
            }

            JetConnection.CreateEmptyDatabase(JetConnection.GetConnectionString(_name + ".accdb"));
            return(true);
        }