public void Will_Error_If_Table_With_Foreign_Key_Has_Cascaded_Data() { tester.DropTable("dbo", "child"); tester.DropTable("dbo", "parent"); tester.ExecuteStatementWithoutResult("create table [dbo].[parent]([id] int primary key, [name] varchar(200));"); tester.ExecuteStatementWithoutResult("create table [dbo].[child]([id] int, [parentid] int not null, [name] varchar(200));"); tester.ExecuteStatementWithoutResult("alter table [dbo].[child] add constraint [FK_parent_child] foreign key ([parentid]) references [dbo].[parent]([id]);"); tester.DropTable("dbo", "parent"); }
public void StatementExecutes() { var sql = "drop table if exists [dbo].[testtable]; create table [dbo].[testtable]([col1] int);"; tester.ExecuteStatementWithoutResult(sql); var statementSuccessful = tester.HasTable("dbo", "testtable"); Assert.IsTrue(statementSuccessful); }
private void DropTable(string schemaName, string tableName) { var dropTableStatement = string.Format("drop table if exists {0}.{1};", schemaName, tableName); tester.ExecuteStatementWithoutResult(dropTableStatement); }
private void DropTable(string schemaName, string tableName) { var sql = DropTableSql(schemaName, tableName); tester.ExecuteStatementWithoutResult(sql); }
public void Will_Clear_Data_From_Table_With_Foreign_Key() { tester.DropTable("dbo", "child"); tester.DropTable("dbo", "parent"); tester.ExecuteStatementWithoutResult("create table [dbo].[parent]([id] int primary key, [name] varchar(200));"); tester.ExecuteStatementWithoutResult("create table [dbo].[child]([id] int, [parentid] int not null, [name] varchar(200));"); tester.ExecuteStatementWithoutResult("alter table [dbo].[child] add constraint [FK_parent_child] foreign key ([parentid]) references [dbo].[parent]([id]);"); tester.ExecuteStatementWithoutResult("insert into [dbo].[parent]([id],[name]) values (1,'testparent');"); tester.ClearTable("dbo", "parent"); Assert.AreEqual(0, tester.RowCount("dbo", "parent")); }