public void CloseSeveralTimes() { int stateChangeCount = 0; JetConnection connection = new JetConnection(ConnectionString); connection.StateChange += (sender, args) => { Console.WriteLine($"{args.OriginalState} => {args.CurrentState}"); stateChangeCount++; }; connection.Close(); connection.Close(); Assert.AreEqual(0, stateChangeCount); }
public void CloseSeveralTimes() { var stateChangeCount = 0; using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.StateChange += (sender, args) => { Console.WriteLine($"{args.OriginalState} => {args.CurrentState}"); stateChangeCount++; }; connection.Close(); connection.Close(); Assert.AreEqual(0, stateChangeCount); }
public void Read_ConnectionString_From_Closed1_Connection() { JetConnection connection = new JetConnection(ConnectionString); connection.Close(); Assert.AreEqual(ConnectionString, connection.ConnectionString); }
public void RenameColumnQuery() { try { JetConnection.ClearAllPools(); File.Delete("AdoxTest.accdb"); } catch (Exception e) { Console.WriteLine(e); } AdoxWrapper.CreateEmptyDatabase(JetConnection.GetConnectionString("AdoxTest.accdb")); using (JetConnection connection = new JetConnection(JetConnection.GetConnectionString("AdoxTest.accdb"))) { connection.Open(); CreateTable(connection); CheckColumnExists(connection, "tableName", "columnName"); connection.CreateCommand("rename column tableName.columnName to newColumnName").ExecuteNonQuery(); connection.Close(); JetConnection.ClearAllPools(); connection.Open(); CheckColumnExists(connection, "tableName", "newColumnName"); } JetConnection.ClearAllPools(); File.Delete("AdoxTest.accdb"); }
public void Transaction_Rollback_Transaction() { using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.Open(); using var firstTransaction = connection.BeginTransaction(); using (var command = connection.CreateCommand("select count(*) from SimpleTable")) { command.Transaction = firstTransaction; command.ExecuteScalar(); } firstTransaction.Rollback(); using var secondTransaction = connection.BeginTransaction(); using (var command = connection.CreateCommand("select count(*) from SimpleTable")) { command.Transaction = secondTransaction; command.ExecuteScalar(); } connection.Close(); connection.Open(); using (var command = connection.CreateCommand("select count(*) from SimpleTable")) { command.ExecuteScalar(); } }
public void Transaction_Rollback_Transaction() { DbCommand command; JetConnection connection = new JetConnection(ConnectionString); connection.Open(); DbTransaction firstTransaction = connection.BeginTransaction(); command = connection.CreateCommand("Select count(*) from SimpleTable"); command.Transaction = firstTransaction; command.ExecuteScalar(); firstTransaction.Rollback(); DbTransaction secondTransaction = connection.BeginTransaction(); command = connection.CreateCommand("Select count(*) from SimpleTable"); command.Transaction = secondTransaction; command.ExecuteScalar(); connection.Close(); connection.Open(); command = connection.CreateCommand("Select count(*) from SimpleTable"); command.ExecuteScalar(); }
public void GetSchema_From_Open_Connection() { using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.Open(); connection.GetSchema(); connection.Close(); }
public void Raise_Events() { var stateChangeCount = 0; using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.StateChange += (sender, args) => { Console.WriteLine($"{args.OriginalState} => {args.CurrentState}"); stateChangeCount++; }; connection.Open(); using var command = connection.CreateCommand("select * from MSysAccessStorage"); var dataReader = command.ExecuteReader(); while (dataReader.Read()) { } connection.Close(); connection.Open(); connection.Dispose(); Assert.AreEqual(4, stateChangeCount); }
//[TestMethod] public void RenameIndexAdox() { try { JetConnection.ClearAllPools(); File.Delete("AdoxTest.accdb"); } catch (Exception e) { Console.WriteLine(e); } AdoxWrapper.CreateEmptyDatabase(JetConnection.GetConnectionString("AdoxTest.accdb")); using (JetConnection connection = new JetConnection(JetConnection.GetConnectionString("AdoxTest.accdb"))) { connection.Open(); CreateTable(connection); CheckIndexExists(connection, "indexName"); AdoxWrapper.RenameIndex(JetConnection.GetConnectionString("AdoxTest.accdb"), "tableName", "indexName", "newIndexName"); connection.Close(); connection.Open(); CheckIndexExists(connection, "newIndexName"); } JetConnection.ClearAllPools(); File.Delete("AdoxTest.accdb"); }
public void TearDown() { _schemaOperationsProvider?.Dispose(); _connection?.Close(); Helpers.DeleteDatabase(StoreName); }
public void GetSchema_From_Open_Connection() { JetConnection connection = new JetConnection(ConnectionString); connection.Open(); connection.GetSchema(); connection.Close(); }
public void Read_ConnectionString_From_Closed1_Connection() { var connectionString = JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory); using var connection = new JetConnection(connectionString); connection.Close(); Assert.AreEqual(connectionString, connection.ConnectionString); }
public void Transaction_Execute_Commit_Commit() { DbCommand command; JetConnection connection = new JetConnection(ConnectionString); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); command = connection.CreateCommand("Select count(*) from SimpleTable"); command.Transaction = transaction; command.ExecuteScalar(); transaction.Commit(); transaction.Commit(); connection.Close(); }
public void Transaction_Execute_Close_Open() { DbCommand command; JetConnection connection = new JetConnection(ConnectionString); connection.Open(); var transaction = connection.BeginTransaction(); command = connection.CreateCommand("INSERT INTO SimpleTable(Col) VALUES ('aaa')"); command.Transaction = transaction; command.ExecuteScalar(); connection.Close(); connection.Open(); command = connection.CreateCommand("Select count(*) from SimpleTable"); Assert.AreEqual(0, command.ExecuteScalar()); }
public void Transaction_Execute_Close_Open_Execute() { DbCommand command; JetConnection connection = new JetConnection(ConnectionString); connection.Open(); var transaction = connection.BeginTransaction(); command = connection.CreateCommand("Select count(*) from MSysAccessStorage"); command.Transaction = transaction; command.ExecuteScalar(); connection.Close(); connection.Open(); command = connection.CreateCommand("Select count(*) from MSysAccessStorage"); command.ExecuteScalar(); }
public void Transaction_Execute_Close_Open() { using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.Open(); using var transaction = connection.BeginTransaction(); using (var command = connection.CreateCommand("INSERT INTO SimpleTable(Col) VALUES ('aaa')")) { command.Transaction = transaction; command.ExecuteScalar(); } connection.Close(); connection.Open(); using (var command = connection.CreateCommand("select count(*) from SimpleTable")) { Assert.AreEqual(0, command.ExecuteScalar()); } }
public void Transaction_Execute_Close_Open_Execute() { using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.Open(); using var transaction = connection.BeginTransaction(); using (var command = connection.CreateCommand("select count(*) from MSysAccessStorage")) { command.Transaction = transaction; command.ExecuteScalar(); } connection.Close(); connection.Open(); using (var command = connection.CreateCommand("select count(*) from MSysAccessStorage")) { command.ExecuteScalar(); } }
public void Transaction_Execute_Commit_Close_Open_Execute() { using var connection = new JetConnection(JetConnection.GetConnectionString(StoreName, Helpers.DataAccessProviderFactory)); connection.Open(); using var transaction = connection.BeginTransaction(); using (var command = connection.CreateCommand($"select count(*) from `{JetConnection.DefaultDualTableName}`")) { command.Transaction = transaction; command.ExecuteScalar(); } transaction.Commit(); connection.Close(); connection.Open(); using (var command = connection.CreateCommand($"select count(*) from `{JetConnection.DefaultDualTableName}`")) { command.ExecuteScalar(); } }
public void Raise_Events() { int stateChangeCount = 0; JetConnection connection = new JetConnection(ConnectionString); connection.StateChange += (sender, args) => { Console.WriteLine($"{args.OriginalState} => {args.CurrentState}"); stateChangeCount++; }; connection.Open(); var dataReader = connection.CreateCommand("Select * from MSysAccessStorage").ExecuteReader(); while (dataReader.Read()) { } connection.Close(); connection.Open(); connection.Dispose(); Assert.AreEqual(4, stateChangeCount); }
public void TearDown() { _connection?.Close(); Helpers.DeleteDatabase(StoreName); }
private void ReOpenConnection() { _connection.Close(); JetConnection.ClearAllPools(); _connection.Open(); }