示例#1
0
        public void ShouldReturnIndexDoesNotExistWhenTableDoesNotExist()
        {
            DatabaseStub srcDB    = new DatabaseStub("SourceDB");
            TableStub    srcTable = srcDB.AddStubbedTable("Table1");
            ColumnStub   srcCol   = srcTable.AddStubbedColumn("Col1", "INT");

            srcTable.AddStubbedIndex(srcCol, "IX_COL1");

            DatabaseStub targetDB = new DatabaseStub("TargetDB");

            Assert.IsFalse(comparer.Index(srcTable.Indexes[0]).ExistsIn(targetDB));
        }
        public void ShouldScriptCreateUniqueIndex()
        {
            SetupResult.For(templateManager.CreateIndex).Return(@"CreateIndex.vm");
            mocks.ReplayAll();

            ColumnStub column = table.AddStubbedColumn("LastName", "NVARCHAR(50)");
            IndexStub  index  = table.AddStubbedIndex(column, "IX_LastName");

            index.unique = true;

            SqlScript script = scriptBuilder.Create(index);
            string    sql    = script.ToScript();

            Console.WriteLine(sql);
            Assert.IsTrue(sql.Contains("IF NOT EXISTS"), "Missing IF NOT EXISTS");
            Assert.IsTrue(sql.Contains("CREATE UNIQUE NONCLUSTERED INDEX [IX_LastName]"),
                          "Missing CREATE NONCLUSTERED INDEX");
            Assert.IsTrue(sql.Contains("[dbo].[Customer]"), "Missing [dbo].[Customer]");
            Assert.IsTrue(sql.Contains("LastName"), "Missing LastName");
        }