Beispiel #1
0
        public void ShouldWriteQueryWithFillFactorAndOptionsForAddUniqueConstraint()
        {
            var schemaName = "schemaName";
            var tableName  = "tableName";

            string[] columnName = new string[] { "column1", "column2" };
            bool     clustered  = true;
            int      fillfactor = 80;

            string[] options   = new string[] { "option1", "options2" };
            string   fileGroup = "fileGroup";

            var op            = new AddUniqueKeyOperation(schemaName, tableName, "name", columnName, clustered, fillfactor, options, fileGroup);
            var expectedQuery = "alter table [schemaName].[tableName] add constraint [name] unique clustered ([column1], [column2]) with (option1, options2, fillfactor = 80) on fileGroup";

            Assert.AreEqual(expectedQuery, op.ToQuery());
        }
Beispiel #2
0
        public void ShouldWriteQueryForAddUniqueConstraintWithCustomName()
        {
            var schemaName = "schemaName";
            var tableName  = "tableName";

            string[] columnName           = new string[] { "column1", "column2" };
            var      customConstraintName = "customConstraintName";
            bool     clustered            = true;
            int      fillfactor           = 0;

            string[] options   = null;
            string   fileGroup = "fileGroup";

            var op            = new AddUniqueKeyOperation(schemaName, tableName, customConstraintName, columnName, clustered, fillfactor, options, fileGroup);
            var expectedQuery = "alter table [schemaName].[tableName] add constraint [customConstraintName] unique clustered ([column1], [column2]) on fileGroup";

            Assert.AreEqual(expectedQuery, op.ToQuery());
        }