Пример #1
0
        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");
        }
Пример #2
0
        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);
        }
Пример #3
0
        private void DropTable(string schemaName, string tableName)
        {
            var dropTableStatement = string.Format("drop table if exists {0}.{1};", schemaName, tableName);

            tester.ExecuteStatementWithoutResult(dropTableStatement);
        }
Пример #4
0
        private void DropTable(string schemaName, string tableName)
        {
            var sql = DropTableSql(schemaName, tableName);

            tester.ExecuteStatementWithoutResult(sql);
        }
Пример #5
0
        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"));
        }