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)); }
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(); }
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(); }
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); }
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); }