Beispiel #1
0
        public void ShouldSetPropertiesForRemoveExtendedProperty()
        {
            //For Schema
            var op = new RemoveExtendedPropertyOperation(SchemaName, Name);

            Assert.AreEqual(true, op.ForSchema);
            Assert.AreEqual(SchemaName, op.SchemaName);
            Assert.AreEqual(Name, op.Name);
            Assert.That(op.TableViewObjectName, Is.Empty);

            //For Table
            op = new RemoveExtendedPropertyOperation(SchemaName, TableName, Name, false);
            Assert.AreEqual(true, op.ForTable);
            Assert.AreEqual(SchemaName, op.SchemaName);
            Assert.AreEqual(TableName, op.TableViewName);
            Assert.AreEqual(Name, op.Name);
            Assert.That(op.TableViewObjectName, Is.EqualTo($"{SchemaName}.{TableName}"));

            //For View
            op = new RemoveExtendedPropertyOperation(SchemaName, ViewName, Name, true);
            Assert.AreEqual(true, op.ForView);
            Assert.AreEqual(SchemaName, op.SchemaName);
            Assert.AreEqual(ViewName, op.TableViewName);
            Assert.AreEqual(Name, op.Name);
            Assert.That(op.TableViewObjectName, Is.EqualTo($"{SchemaName}.{ViewName}"));

            //For Column
            op = new RemoveExtendedPropertyOperation(SchemaName, TableName, ColumnName, Name, false);
            Assert.AreEqual(true, op.ForColumn);
            Assert.AreEqual(SchemaName, op.SchemaName);
            Assert.AreEqual(TableName, op.TableViewName);
            Assert.AreEqual(ColumnName, op.ColumnName);
            Assert.AreEqual(Name, op.Name);
            Assert.That(op.TableViewObjectName, Is.EqualTo($"{SchemaName}.{TableName}"));
        }
Beispiel #2
0
        private void GivenSchemaProperty()
        {
            var schemaName = Guid.NewGuid().ToString();
            var name       = Guid.NewGuid().ToString();

            _op = new RemoveExtendedPropertyOperation(schemaName, name);
        }
        public void ShouldDisableAddSchemaPropertyIfRemovedByMerge()
        {
            var op       = new AddExtendedPropertyOperation("schema", "name", "value");
            var removeOp = new RemoveExtendedPropertyOperation("SCHEMA", "NAME");

            op.Merge(removeOp);
            Assert.That(op.Disabled, Is.True);
            Assert.That(removeOp.Disabled, Is.True);
        }
        public void ShouldDisableAddViewOrTablePropertyIfRemovedByMerge(bool forView)
        {
            var op       = new AddExtendedPropertyOperation("schema", "tableOrView", "name", "value", forView);
            var removeOp = new RemoveExtendedPropertyOperation("SCHEMA", "TABLEORVIEW", "NAME", forView);

            op.Merge(removeOp);
            Assert.That(op.Disabled, Is.True);
            Assert.That(removeOp.Disabled, Is.True);
        }
        public void ShouldRemoveIfRemovingSchemaPropertyAndSchemaGettingRemoved()
        {
            var op             = new RemoveExtendedPropertyOperation("schema", "name");
            var removeSchemaOp = new RemoveSchemaOperation("SCHEMA");

            op.Merge(removeSchemaOp);
            Assert.That(op.Disabled, Is.True);
            Assert.That(removeSchemaOp.Disabled, Is.False);
        }
Beispiel #6
0
        private void GivenViewColumnProperty()
        {
            var schemaName = Guid.NewGuid().ToString();
            var viewName   = Guid.NewGuid().ToString();
            var columnName = Guid.NewGuid().ToString();
            var name       = Guid.NewGuid().ToString();

            _op = new RemoveExtendedPropertyOperation(schemaName, viewName, columnName, name, true);
        }
Beispiel #7
0
        private void GivenTableColumnProperty()
        {
            var schemaName = Guid.NewGuid().ToString();
            var tableName  = Guid.NewGuid().ToString();
            var columnName = Guid.NewGuid().ToString();
            var name       = Guid.NewGuid().ToString();

            _op = new RemoveExtendedPropertyOperation(schemaName, tableName, columnName, name, false);
        }
Beispiel #8
0
        private void Generate(RemoveExtendedPropertyOperation operation, MigrationCommandListBuilder builder)
        {
            builder.Append("EXEC sys.sp_dropextendedproperty");
            builder.Append($" @name = N'{operation.ExtendedProperty.Key}'");
            builder.Append(", @level0type = N'SCHEMA'");
            builder.Append($", @level0name = N'{operation.SchemaTableColumn.Schema ?? "dbo"}'");
            builder.Append(", @level1type = N'TABLE'");
            builder.Append($", @level1name = N'{operation.SchemaTableColumn.Table}'");

            if (!String.IsNullOrEmpty(operation.SchemaTableColumn.Column))
            {
                builder.Append($@",@level2type = 'COLUMN', @level2name = '{operation.SchemaTableColumn.Column}'");
            }

            builder.EndCommand();
        }