Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        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"]);
        }
Esempio n. 4
0
        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);
        }