DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Deveel.Data.Sql.Statements.AlterTableStatementTests Class Reference
Inheritance diagram for Deveel.Data.Sql.Statements.AlterTableStatementTests:
Deveel.Data.ContextBasedTest

Public Member Functions

void AlterTableAddColumn ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Protected Member Functions

override void OnSetUp (string testName)
 
- Protected Member Functions inherited from Deveel.Data.ContextBasedTest
virtual void RegisterServices (ServiceContainer container)
 
virtual ISystem CreateSystem ()
 
virtual IDatabase CreateDatabase (ISystem system, IConfiguration configuration)
 
virtual ISession CreateAdminSession (IDatabase database)
 
virtual IQuery CreateQuery (ISession session)
 
ISession CreateUserSession (string userName, string password)
 
virtual void OnTearDown ()
 

Private Member Functions

void CreateTestTable ()
 

Additional Inherited Members

- Protected Attributes inherited from Deveel.Data.ContextBasedTest
const string AdminUserName = "SA"
 
const string AdminPassword = "1234567890"
 
const string DatabaseName = "testdb"
 
- Properties inherited from Deveel.Data.ContextBasedTest
virtual bool SingleContext [get]
 
IQuery Query [get, private set]
 
ISystem System [get, private set]
 
IDatabase Database [get, private set]
 
ISession Session [get, private set]
 

Detailed Description

Definition at line 29 of file AlterTableStatementTests.cs.

Member Function Documentation

void Deveel.Data.Sql.Statements.AlterTableStatementTests.AlterTableAddColumn ( )
inline

Definition at line 49 of file AlterTableStatementTests.cs.

49  {
50  const string sql = "ALTER TABLE test_table ADD COLUMN reserved BOOLEAN";
51 
52  IEnumerable<SqlStatement> statements = null;
53  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
54  Assert.IsNotNull(statements);
55 
56  var list = statements.ToList();
57 
58  Assert.AreEqual(1, list.Count);
59 
60  var statement = list[0];
61 
62  Assert.IsNotNull(statement);
63  Assert.IsInstanceOf<AlterTableStatement>(statement);
64 
65  ITable result = null;
66  Assert.DoesNotThrow(() => result = statement.Execute(Query));
67  Assert.IsNotNull(result);
68  Assert.AreEqual(1, result.RowCount);
69  Assert.AreEqual(1, result.TableInfo.ColumnCount);
70  Assert.AreEqual(0, ((SqlNumber) result.GetValue(0,0).Value).ToInt32());
71 
72  var testTable = Query.GetTable(new ObjectName("test_table"));
73 
74  Assert.IsNotNull(testTable);
75  Assert.AreEqual(6, testTable.TableInfo.ColumnCount);
76  }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
void Deveel.Data.Sql.Statements.AlterTableStatementTests.CreateTestTable ( )
inlineprivate

Definition at line 34 of file AlterTableStatementTests.cs.

34  {
35  var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
36  var idColumn = tableInfo.AddColumn("id", PrimitiveTypes.Integer());
37  idColumn.DefaultExpression = SqlExpression.FunctionCall("UNIQUE_KEY",
38  new SqlExpression[] { SqlExpression.Reference(tableInfo.TableName) });
39  tableInfo.AddColumn("first_name", PrimitiveTypes.String());
40  tableInfo.AddColumn("last_name", PrimitiveTypes.String());
41  tableInfo.AddColumn("birth_date", PrimitiveTypes.DateTime());
42  tableInfo.AddColumn("active", PrimitiveTypes.Boolean());
43 
44  Query.CreateTable(tableInfo);
45  Query.AddPrimaryKey(tableInfo.TableName, "id", "PK_TEST_TABLE");
46  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static BooleanType Boolean()
void AddColumn(ColumnInfo column)
Adds a new column to the table at the last position of the columns list in the table metadata...
Definition: TableInfo.cs:230
static SqlReferenceExpression Reference(ObjectName objectName)
Defines the base class for instances that represent SQL expression tree nodes.
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
override void Deveel.Data.Sql.Statements.AlterTableStatementTests.OnSetUp ( string  testName)
inlineprotectedvirtual

The documentation for this class was generated from the following file: