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

Public Member Functions

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

Protected Member Functions

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

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 25 of file DropTableTests.cs.

Member Function Documentation

override ISession Deveel.Data.Sql.DropTableTests.CreateAdminSession ( IDatabase  database)
inlineprotectedvirtual

Reimplemented from Deveel.Data.ContextBasedTest.

Definition at line 26 of file DropTableTests.cs.

26  {
27  using (var session = base.CreateAdminSession(database)) {
28  using (var query = session.CreateQuery()) {
29  var tn1 = ObjectName.Parse("APP.test_table1");
30  var tableInfo1 = new TableInfo(tn1);
31  tableInfo1.AddColumn(new ColumnInfo("id", PrimitiveTypes.Integer()));
32  tableInfo1.AddColumn(new ColumnInfo("name", PrimitiveTypes.String()));
33  tableInfo1.AddColumn(new ColumnInfo("date", PrimitiveTypes.DateTime()));
34  query.CreateTable(tableInfo1);
35  query.AddPrimaryKey(tn1, "id");
36 
37  var tn2 = ObjectName.Parse("APP.test_table2");
38  var tableInfo2 = new TableInfo(tn2);
39  tableInfo2.AddColumn(new ColumnInfo("id", PrimitiveTypes.Integer()));
40  tableInfo2.AddColumn(new ColumnInfo("other_id", PrimitiveTypes.Integer()));
41  tableInfo2.AddColumn(new ColumnInfo("count", PrimitiveTypes.Integer()));
42  query.CreateTable(tableInfo2);
43  query.AddPrimaryKey(tn2, "id");
44  query.AddForeignKey(tn2, new[] { "other_id" }, tn1, new[] { "id" }, ForeignKeyAction.Cascade, ForeignKeyAction.Cascade, null);
45 
46  query.Commit();
47  }
48  }
49 
50  return base.CreateAdminSession(database);
51  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
Defines the metadata properties of a column within a table of a database.
Definition: ColumnInfo.cs:36
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
void Deveel.Data.Sql.DropTableTests.DropAllTables ( )
inline

Definition at line 74 of file DropTableTests.cs.

74  {
75  var tableNames = new[] {
76  ObjectName.Parse("APP.test_table1"),
77  ObjectName.Parse("APP.test_table2"),
78  };
79 
80  Assert.DoesNotThrow(() => Query.DropTables(tableNames));
81  }
void Deveel.Data.Sql.DropTableTests.DropNonReferencedTable ( )
inline

Definition at line 54 of file DropTableTests.cs.

54  {
55  var tableName = ObjectName.Parse("APP.test_table2");
56  Assert.DoesNotThrow(() => Query.DropTable(tableName));
57 
58  bool exists = false;
59  Assert.DoesNotThrow(() => exists = Query.TableExists(tableName));
60  Assert.IsFalse(exists);
61  }
void Deveel.Data.Sql.DropTableTests.DropReferencedTable ( )
inline

Definition at line 64 of file DropTableTests.cs.

64  {
65  var tableName = ObjectName.Parse("APP.test_table1");
66  Assert.Throws<ConstraintViolationException>(() => Query.DropTable(tableName));
67 
68  bool exists = false;
69  Assert.DoesNotThrow(() => exists = Query.TableExists(tableName));
70  Assert.IsTrue(exists);
71  }
A database exception that represents a constraint violation.

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