Inheritance: IMigrationProvider
 public void SqlFormatterAddIndexTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "6" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     migrations.SetMigrationNumber(5); // add index
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("6"));
     Assert.True(file_writer.FileContents.Contains("CREATE NONCLUSTERED INDEX [IX_categories_title_slug] ON [categories] ( [title] ASC, [slug] ASC )"));
 }
        public void SqlFormatterDropTableTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "2" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            migrations.SetMigrationNumber(2); // drop table
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("2"));
            Assert.True(file_writer.FileContents.Contains("DROP TABLE [tname]"));
        }
        public void SqlFormatterDropIndexTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "7" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            migrations.SetMigrationNumber(6); // add index
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("7"));
            Assert.True(file_writer.FileContents.Contains("DROP INDEX [categories].[IX_categories_title_slug]"));
        }
        public void SqlFormatterAddIndexTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "6" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            migrations.SetMigrationNumber(5); // add index
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("6"));
            Assert.True(file_writer.FileContents.Contains("CREATE NONCLUSTERED INDEX [IX_categories_title_slug] ON [categories] ( [title] ASC, [slug] ASC )"));
        }
 public void SqlFormatterAddColumnTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "3" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     migrations.SetMigrationNumber(3); // add col
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("3"));
     Assert.True(file_writer.FileContents.Contains("ALTER TABLE [tname]"));
     Assert.True(file_writer.FileContents.Contains("ADD [name]"));
     Assert.True(file_writer.FileContents.Contains("nvarchar(255)"));
 }
 public void SqlFormatterAddColumnReferenceTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "9" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     //migrations.SetMigrationNumber(9); // add col
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("9"));
     Assert.True(file_writer.FileContents.Contains("FK_orders_user_userid"));
     Assert.True(file_writer.FileContents.Contains("ALTER TABLE [Orders] ADD [UserId] INT NOT NULL"));
     Assert.True(file_writer.FileContents.Contains("ALTER TABLE [Orders] ADD CONSTRAINT [FK_orders_user_userid] FOREIGN KEY ([UserId]) REFERENCES [User] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION"));
 }
        public void SqlFormatterDropColumnTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "5" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            migrations.SetMigrationNumber(4); // change col
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.IsTrue(file_writer.FileName.Contains("5"));
            Assert.IsTrue(file_writer.FileContents.Contains("ALTER TABLE [tname]"));
            Assert.IsTrue(file_writer.FileContents.Contains("DROP COLUMN [name]"));
        }
        public void SqlFormatterAddColumnTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "3" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            migrations.SetMigrationNumber(3); // add col
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("3"));
            Assert.True(file_writer.FileContents.Contains("ALTER TABLE [tname]"));
            Assert.True(file_writer.FileContents.Contains("ADD [name]"));
            Assert.True(file_writer.FileContents.Contains("nvarchar(255)"));
        }
        public void SqlFormatterAddColumnReferenceTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "9" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            //migrations.SetMigrationNumber(9); // add col
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("9"));
            Assert.True(file_writer.FileContents.Contains("FK_orders_user_userid"));
            Assert.True(file_writer.FileContents.Contains("ALTER TABLE [Orders] ADD [UserId] INT NOT NULL"));
            Assert.True(file_writer.FileContents.Contains("ALTER TABLE [Orders] ADD CONSTRAINT [FK_orders_user_userid] FOREIGN KEY ([UserId]) REFERENCES [User] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION"));
        }
 public void SqlFormatterAddTableReferenceTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "10" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     //migrations.SetMigrationNumber(10); // add col
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("10"));
     Assert.True(file_writer.FileContents.Contains("FK_applicationcontrol_applicationpage_applicationpageid"));
     Assert.True(file_writer.FileContents.Contains("FK_applicationcontrol_application_applicationid"));
     Assert.True(file_writer.FileContents.Contains("FOREIGN KEY ([ApplicationPageId]) REFERENCES [ApplicationPage] ([Id])"));
     Assert.True(file_writer.FileContents.Contains("FOREIGN KEY ([ApplicationId]) REFERENCES [Application] ([Id])"));
 }
        public void SqlFormatterAddTableReferenceTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "10" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            //migrations.SetMigrationNumber(10); // add col
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("10"));
            Assert.True(file_writer.FileContents.Contains("FK_applicationcontrol_applicationpage_applicationpageid"));
            Assert.True(file_writer.FileContents.Contains("FK_applicationcontrol_application_applicationid"));
            Assert.True(file_writer.FileContents.Contains("FOREIGN KEY ([ApplicationPageId]) REFERENCES [ApplicationPage] ([Id])"));
            Assert.True(file_writer.FileContents.Contains("FOREIGN KEY ([ApplicationId]) REFERENCES [Application] ([Id])"));
        }
        public void SqlFormatterAddTableTest()
        {
            Configuration      configuration = new Configuration(new[] { "-s", "1" });
            TestFileWriter     file_writer   = new TestFileWriter();
            ISqlFormatter      formatter     = new SQLServerFormatter(configuration, Settings);
            IMigrationProvider migrations    = new TestMigrationProvider();
            IHumpbackCommand   target        = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);

            migrations.SetMigrationNumber(1); // create table
            target.Execute();
            Console.WriteLine(file_writer.FileContents);
            Assert.True(file_writer.FileName.Contains("1"));
            Assert.True(file_writer.FileContents.Contains("CREATE TABLE [tname]"));
            Assert.True(file_writer.FileContents.Contains("[first_name] nvarchar(255)"));
            Assert.True(file_writer.FileContents.Contains("[last_name] decimal"));
            Assert.True(file_writer.FileContents.Contains("CreatedOn datetime DEFAULT getutcdate() NOT NULL"));
            Assert.True(file_writer.FileContents.Contains("Id"));
            Assert.True(file_writer.FileContents.Contains("PRIMARY KEY"));
        }
 public void SqlFormatterAddTableTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "1" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     migrations.SetMigrationNumber(1); // create table
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("1"));
     Assert.True(file_writer.FileContents.Contains("CREATE TABLE [tname]"));
     Assert.True(file_writer.FileContents.Contains("[first_name] nvarchar(255)"));
     Assert.True(file_writer.FileContents.Contains("[last_name] decimal"));
     Assert.True(file_writer.FileContents.Contains("CreatedOn datetime DEFAULT getutcdate() NOT NULL"));
     Assert.True(file_writer.FileContents.Contains("Id"));
     Assert.True(file_writer.FileContents.Contains("PRIMARY KEY"));
 }
 public void SqlFormatterDropTableTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "2" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     migrations.SetMigrationNumber(2); // drop table
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("2"));
     Assert.True(file_writer.FileContents.Contains("DROP TABLE [tname]"));
 }
 public void SqlFormatterDropIndexTest()
 {
     Configuration configuration = new Configuration(new[] { "-s", "7" });
     TestFileWriter file_writer = new TestFileWriter();
     ISqlFormatter formatter = new SQLServerFormatter(configuration, Settings);
     IMigrationProvider migrations = new TestMigrationProvider();
     IHumpbackCommand target = new GenerateSQL(configuration, Settings, formatter, file_writer, migrations);
     migrations.SetMigrationNumber(6); // add index
     target.Execute();
     Console.WriteLine(file_writer.FileContents);
     Assert.True(file_writer.FileName.Contains("7"));
     Assert.True(file_writer.FileContents.Contains("DROP INDEX [categories].[IX_categories_title_slug]"));
 }