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

Public Member Functions

void ParseSimpleCreate ()
 
void SimpleCreate ()
 
void WithColumnDefault ()
 
void ParseWithColumnDefault ()
 
void ParseWithColumnIdentity ()
 
void ParseWithColumnConstraints ()
 
void ParseWithColumnAndTableConstraints ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Additional Inherited Members

- 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 OnSetUp (string testName)
 
virtual void OnTearDown ()
 
- 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 28 of file CreateTableStatementTests.cs.

Member Function Documentation

void Deveel.Data.Sql.Statements.CreateTableStatementTests.ParseSimpleCreate ( )
inline

Definition at line 30 of file CreateTableStatementTests.cs.

30  {
31  const string sql = "CREATE TABLE test (id INT, name VARCHAR)";
32 
33  IEnumerable<SqlStatement> statements = null;
34  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
35  Assert.IsNotNull(statements);
36 
37  var list = statements.ToList();
38 
39  Assert.AreEqual(1, list.Count);
40 
41  var statement = list[0];
42 
43  Assert.IsNotNull(statement);
44  Assert.IsInstanceOf<CreateTableStatement>(statement);
45 
46  var createTable = (CreateTableStatement) statement;
47  Assert.AreEqual(2, createTable.Columns.Count);
48 
49  var columns = createTable.Columns;
50 
51  Assert.AreEqual("id", columns[0].ColumnName);
52  Assert.AreEqual(SqlTypeCode.Integer, columns[0].ColumnType.TypeCode);
53 
54  Assert.AreEqual("name", columns[1].ColumnName);
55  Assert.IsInstanceOf<StringType>(columns[1].ColumnType);
56  }
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Statements.CreateTableStatementTests.ParseWithColumnAndTableConstraints ( )
inline

Definition at line 186 of file CreateTableStatementTests.cs.

186  {
187  const string sql = "CREATE TABLE test (id INT PRIMARY KEY, name VARCHAR NOT NULL, CONSTRAINT uk_test UNIQUE(name))";
188 
189  IEnumerable<SqlStatement> statements = null;
190  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
191  Assert.IsNotNull(statements);
192 
193  var list = statements.ToList();
194 
195  Assert.AreEqual(3, list.Count);
196  }
void Deveel.Data.Sql.Statements.CreateTableStatementTests.ParseWithColumnConstraints ( )
inline

Definition at line 173 of file CreateTableStatementTests.cs.

173  {
174  const string sql = "CREATE TABLE test (id INT PRIMARY KEY, name VARCHAR NOT NULL)";
175 
176  IEnumerable<SqlStatement> statements = null;
177  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
178  Assert.IsNotNull(statements);
179 
180  var list = statements.ToList();
181 
182  Assert.AreEqual(2, list.Count);
183  }
void Deveel.Data.Sql.Statements.CreateTableStatementTests.ParseWithColumnDefault ( )
inline

Definition at line 105 of file CreateTableStatementTests.cs.

105  {
106  const string sql = "CREATE TABLE test (id INT, name VARCHAR DEFAULT (67 * 90)+22, date TIMESTAMP DEFAULT GetDate())";
107 
108  IEnumerable<SqlStatement> statements = null;
109  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
110  Assert.IsNotNull(statements);
111 
112  var list = statements.ToList();
113 
114  Assert.AreEqual(1, list.Count);
115 
116  var statement = list[0];
117 
118  Assert.IsNotNull(statement);
119  Assert.IsInstanceOf<CreateTableStatement>(statement);
120 
121  var createTable = (CreateTableStatement)statement;
122  Assert.AreEqual(3, createTable.Columns.Count);
123 
124  var columns = createTable.Columns;
125 
126  Assert.AreEqual("id", columns[0].ColumnName);
127  Assert.AreEqual(SqlTypeCode.Integer, columns[0].ColumnType.TypeCode);
128 
129  Assert.AreEqual("name", columns[1].ColumnName);
130  Assert.IsInstanceOf<StringType>(columns[1].ColumnType);
131  Assert.IsTrue(columns[1].HasDefaultExpression);
132  Assert.IsInstanceOf<SqlBinaryExpression>(columns[1].DefaultExpression);
133 
134  Assert.AreEqual("date", columns[2].ColumnName);
135  Assert.IsInstanceOf<DateType>(columns[2].ColumnType);
136  Assert.IsTrue(columns[1].HasDefaultExpression);
137  Assert.IsInstanceOf<SqlFunctionCallExpression>(columns[2].DefaultExpression);
138  }
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Statements.CreateTableStatementTests.ParseWithColumnIdentity ( )
inline

Definition at line 141 of file CreateTableStatementTests.cs.

141  {
142  const string sql = "CREATE TABLE test (id INT IDENTITY, name VARCHAR NOT NULL)";
143 
144  IEnumerable<SqlStatement> statements = null;
145  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
146  Assert.IsNotNull(statements);
147 
148  var list = statements.ToList();
149 
150  Assert.AreEqual(1, list.Count);
151 
152  var statement = list[0];
153 
154  Assert.IsNotNull(statement);
155  Assert.IsInstanceOf<CreateTableStatement>(statement);
156 
157  var createTable = (CreateTableStatement)statement;
158  Assert.AreEqual(2, createTable.Columns.Count);
159 
160  var columns = createTable.Columns;
161 
162  Assert.AreEqual("id", columns[0].ColumnName);
163  Assert.AreEqual(SqlTypeCode.Integer, columns[0].ColumnType.TypeCode);
164  Assert.IsNotNull(columns[0].DefaultExpression);
165  Assert.IsInstanceOf<SqlFunctionCallExpression>(columns[0].DefaultExpression);
166 
167  Assert.AreEqual("name", columns[1].ColumnName);
168  Assert.IsInstanceOf<StringType>(columns[1].ColumnType);
169  Assert.IsTrue(columns[1].IsNotNull);
170  }
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Statements.CreateTableStatementTests.SimpleCreate ( )
inline

Definition at line 59 of file CreateTableStatementTests.cs.

59  {
60  const string sql = "CREATE TABLE test (id INT, name VARCHAR)";
61 
62  IEnumerable<SqlStatement> statements = null;
63  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
64  Assert.IsNotNull(statements);
65 
66  var list = statements.ToList();
67 
68  Assert.AreEqual(1, list.Count);
69 
70  var statement = list[0];
71 
72  Assert.IsNotNull(statement);
73  Assert.IsInstanceOf<CreateTableStatement>(statement);
74 
75  ITable result = null;
76  Assert.DoesNotThrow(() => result = statement.Execute(Query));
77  Assert.IsNotNull(result);
78  Assert.AreEqual(1, result.RowCount);
79  }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
void Deveel.Data.Sql.Statements.CreateTableStatementTests.WithColumnDefault ( )
inline

Definition at line 82 of file CreateTableStatementTests.cs.

82  {
83  const string sql = "CREATE TABLE test (id INT, name VARCHAR DEFAULT (67 * 90)+22, date TIMESTAMP DEFAULT GetDate())";
84 
85  IEnumerable<SqlStatement> statements = null;
86  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
87  Assert.IsNotNull(statements);
88 
89  var list = statements.ToList();
90 
91  Assert.AreEqual(1, list.Count);
92 
93  var statement = list[0];
94 
95  Assert.IsNotNull(statement);
96  Assert.IsInstanceOf<CreateTableStatement>(statement);
97 
98  ITable result = null;
99  Assert.DoesNotThrow(() => result = statement.Execute(Query));
100  Assert.IsNotNull(result);
101  Assert.AreEqual(1, result.RowCount);
102  }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40

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