Ejemplo n.º 1
0
        public void ShouldDisableWhenMergedWithRemoveOperation()
        {
            var op       = new AddSchemaOperation("name", "owner");
            var removeOp = new RemoveSchemaOperation("NAME");

            op.Merge(removeOp);
            Assert.That(op.Disabled, Is.True);
            Assert.That(removeOp.Disabled, Is.True);
        }
Ejemplo n.º 2
0
        public void ShouldSetPropertiesForSchema()
        {
            const string schemaName  = "schemaName";
            const string schemaOwner = "schemaOwner";

            //Test for Input with Both Schema and Owner
            var op = new AddSchemaOperation(schemaName, schemaOwner);

            Assert.That(op.Name, Is.EqualTo(schemaName));
            Assert.That(op.Owner, Is.EqualTo(schemaOwner));
            //Assert.That(op.ObjectName, Is.EqualTo(schemaName));

            var expectedQuery = string.Format("if not exists (select * from sys.schemas where name = '{0}'){1}    exec sp_executesql N'create schema [{0}] authorization [{2}]'", schemaName, Environment.NewLine, schemaOwner);

            Assert.That(op.ToQuery(), Is.EqualTo(expectedQuery));

            //Test for Input with Schema Only
            op = new AddSchemaOperation(schemaName, null);
            Assert.That(op.Name, Is.EqualTo(schemaName));
            Assert.That(op.Owner, Is.EqualTo(null));

            expectedQuery = string.Format("if not exists (select * from sys.schemas where name = '{0}'){1}    exec sp_executesql N'create schema [{0}]'", schemaName, Environment.NewLine);
            Assert.That(op.ToQuery(), Is.EqualTo(expectedQuery));
        }