public void GetDatabaseAndDatasource()
        {
            AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise;Data Source=MyDataSource");

            Assert.AreEqual("MyEnterprise", connection.Database);
            Assert.AreEqual("MyDataSource", connection.DataSource);
        }
Beispiel #2
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);
        }
        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"));
        }
Beispiel #5
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"]);
        }
Beispiel #6
0
 public AjBaseCommand(string commandText, AjBaseConnection connection)
 {
     this.commandText = commandText;
     this.connection  = connection;
 }
Beispiel #7
0
 public AjBaseCommand(string commandText, AjBaseConnection connection)
 {
     this.commandText = commandText;
     this.connection = connection;
 }
        public void RaiseIfConnectionStringIsEmpty()
        {
            AjBaseConnection connection = new AjBaseConnection("");

            Assert.AreEqual("MyEnterprise", connection.Database);
        }
        public void GetNullDatasourceIfNotDefined()
        {
            AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise");

            Assert.IsNull(connection.DataSource);
        }
Beispiel #10
0
        public void GetDatasource()
        {
            AjBaseConnection connection = new AjBaseConnection("Data Source=MyDataSource");

            Assert.AreEqual("MyDataSource", connection.DataSource);
        }
Beispiel #11
0
        public void GetDatabase()
        {
            AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise");

            Assert.AreEqual("MyEnterprise", connection.Database);
        }
Beispiel #12
0
        public void CreateWithConnectionString()
        {
            AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise");

            Assert.AreEqual("Database=MyEnterprise", connection.ConnectionString);
        }
Beispiel #13
0
        public void SetConnectionString()
        {
            AjBaseConnection connection = new AjBaseConnection();
            connection.ConnectionString = "Database=MyEnterprise";

            Assert.AreEqual("Database=MyEnterprise", connection.ConnectionString);
        }
Beispiel #14
0
        public void RaiseIfDatabaseDoesNotExistWhenOpen()
        {
            AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise");

            connection.Open();
        }
Beispiel #15
0
        public void RaiseIfDatabaseDefinedTwice()
        {
            AjBaseConnection connection = new AjBaseConnection("Database=MyEnterprise;Database=OtherEnterprise");

            Assert.AreEqual("MyEnterprise", connection.Database);
        }