public void ExecuteCreateCommand() { int initial = this.table.GetRows().Count; AjBaseConnection connection = new AjBaseConnection("Database=Sales"); AjBaseCommand command = new AjBaseCommand("create table Customers(Name, Address)", connection); connection.Open(); // TODO test return command.ExecuteNonQuery(); connection.Close(); Table table = this.database.GetTable("Customers"); Assert.IsNotNull(table); }
public void OpenAndCloseExistingDatabase() { Engine engine = new Engine(); engine.CreateDatabase("MyEnterprise"); Engine.Current = engine; AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise"); connection.Open(); Assert.AreEqual(ConnectionState.Open, connection.State); connection.Close(); Assert.AreEqual(ConnectionState.Closed, connection.State); }
public void CreateDatabaseDatabase() { Engine engine = new Engine(); Engine.Current = engine; AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise;CreateIfNotExists=true"); connection.Open(); Assert.AreEqual(ConnectionState.Open, connection.State); connection.Close(); Assert.AreEqual(ConnectionState.Closed, connection.State); Assert.IsNotNull(engine.GetDatabase("MyEnterprise")); }
public void ExecuteInsertCommand() { int initial = this.table.GetRows().Count; AjBaseConnection connection = new AjBaseConnection("Database=Sales"); AjBaseCommand command = new AjBaseCommand("insert into Employees(FirstName, LastName) values('New First Name', 'New Last Name')", connection); connection.Open(); int n = command.ExecuteNonQuery(); connection.Close(); Assert.AreEqual(1, n); Assert.AreEqual(initial + 1, this.table.GetRows().Count()); Row row = this.table.GetRows().Last(); Assert.AreEqual("New First Name", row["FirstName"]); Assert.AreEqual("New Last Name", row["LastName"]); }
public void RaiseIfDatabaseDoesNotExistWhenOpen() { AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise"); connection.Open(); }