public void ShouldDisableWhenMergedWithRemoveOperation() { var op = new AddForeignKeyOperation("schema", "table", "name", new string[0], "ref_schema", "ref_table", new string[0], "delete", "update", false, false); var removeOp = new RemoveForeignKeyOperation("SCHEMA", "TABLE", "NAME"); op.Merge(removeOp); Assert.That(op.Disabled, Is.True); Assert.That(removeOp.Disabled, Is.True); }
public void ShouldNotChangeConstraintReferencedTableNameIfANonReferencedTableRenamed(string schemaName, string tableName) { var op = new AddForeignKeyOperation("schema", "table", "name", new string[0], "ref schema", "ref table", new string[0], "on delete", "on update", false, false); var renameTableOp = new RenameObjectOperation(schemaName, tableName, "new table"); op.Merge(renameTableOp); Assert.That(op.Disabled, Is.False); Assert.That(renameTableOp.Disabled, Is.False); Assert.That(op.ReferencesTableName, Is.EqualTo("ref table")); }
public void ShouldChangeConstraintReferencedTableNameIfReferencedTableRenamed() { var op = new AddForeignKeyOperation("schema", "table", "name", new string[0], "ref schema", "ref table", new string[0], "on delete", "on update", false, false); var renameTableOp = new RenameObjectOperation("REF SCHEMA", "REF TABLE", "new table"); op.Merge(renameTableOp); Assert.That(op.Disabled, Is.False); Assert.That(renameTableOp.Disabled, Is.True); Assert.That(op.ReferencesTableName, Is.EqualTo(renameTableOp.NewName)); }
public void ShouldNotDisableAddIfRemovingAForeignKeyOnTheSameTable() { var op = new AddForeignKeyOperation("schema", "table", "name", new string[0], "ref schema", "ref table", new string[0], "on delete", "on update", false, false); var removeOp = new RemoveForeignKeyOperation("schema", "table", "name2"); op.Merge(removeOp); Assert.That(removeOp.Disabled, Is.False); Assert.That(op.Disabled, Is.False); }
public void ShouldChangeConstraintName() { var op = new AddForeignKeyOperation("schema", "table", "name", new string[0], "ref schema", "ref table", new string[0], "on delete", "on update", false, false); var renameOp = new RenameObjectOperation("SCHEMA", "NAME", "new name"); op.Merge(renameOp); Assert.That(op.Name, Is.EqualTo("new name")); Assert.That(renameOp.Disabled); Assert.That(op.Disabled, Is.False); }
public void ShouldRenameSourceColumnIfRenamed() { var op = new AddForeignKeyOperation("schema", "table", "name", new[] { "column", "column2" }, "ref schema", "ref table", new string[] { "ref column", "ref column2" }, "on delete", "on update", false, false); var renameColumnOp = new RenameColumnOperation("SCHEMA", "TABLE", "COLUMN", "new column"); op.Merge(renameColumnOp); Assert.That(op.Disabled, Is.False); Assert.That(renameColumnOp.Disabled, Is.True); Assert.That(op.ColumnName[0], Is.EqualTo("new column")); Assert.That(op.ColumnName[1], Is.EqualTo("column2")); Assert.That(op.ReferencesColumnName[0], Is.EqualTo("ref column")); Assert.That(op.ReferencesColumnName[1], Is.EqualTo("ref column2")); }
public void ShouldNotRenameReferenceColumnIfReferencesDifferentTableThatIsRenamed(string schemaName, string tableName) { var op = new AddForeignKeyOperation("schema", "table", "name", new[] { "column", "column2" }, "ref schema", "ref table", new string[] { "ref column", "ref column2" }, "on delete", "on update", false, false); var renameColumnOp = new RenameColumnOperation(schemaName, tableName, "REF COLUMN", "new column"); op.Merge(renameColumnOp); Assert.That(op.Disabled, Is.False); Assert.That(renameColumnOp.Disabled, Is.False); Assert.That(op.ColumnName[0], Is.EqualTo("column")); Assert.That(op.ColumnName[1], Is.EqualTo("column2")); Assert.That(op.ReferencesColumnName[0], Is.EqualTo("ref column")); Assert.That(op.ReferencesColumnName[1], Is.EqualTo("ref column2")); }