Exemplo n.º 1
0
 public void CreateTableWorks() {
     var config = new SimpleClassConfig();
     var migrator = MakeMigrator(config);
     IEnumerable<string> errors;
     IEnumerable<string> warnings;
     var script = migrator.GenerateSqlDiff(
         new IMap[] { },
         config.Maps,
         null,
         new Mock<ILogger>().Object,
         new string[0],
         out warnings,
         out errors);
     Assert.Equal(
         "create table [SimpleClasses] ([SimpleClassId] int not null identity(1,1) primary key, [Name] nvarchar(255) null, [CreatedDate] datetime not null default (current_timestamp));",
         script.Trim());
 }
Exemplo n.º 2
0
 public void NonIgnoredIndexDropped() {
     var migrator = MakeMigrator();
     var config = new SimpleClassConfig();
     var config2 = new SimpleClassConfig();
     config.Maps.ElementAt(0)
           .AddIndex(new Index(config.Maps.ElementAt(0), new[] { config.Maps.ElementAt(0).Columns.First().Value }, "Foo", false));
     IEnumerable<string> warnings;
     IEnumerable<string> errors;
     var script = migrator.GenerateSqlDiff(
         config.Maps,
         config2.Maps,
         null,
         new Mock<ILogger>().Object,
         new string[0],
         out warnings,
         out errors);
     Assert.Equal(@"drop index [Foo] on [SimpleClasses];", script.Trim());
 }
Exemplo n.º 3
0
 public void IgnoredIndexNotDeleted() {
     var migrator = MakeMigrator();
     var config = new SimpleClassConfig();
     var config2 = new SimpleClassConfig();
     config.Maps.ElementAt(0)
           .AddIndex(new Index(config.Maps.ElementAt(0), new[] { config.Maps.ElementAt(0).Columns.First().Value }, "Foo", false));
     IEnumerable<string> warnings;
     IEnumerable<string> errors;
     var script = migrator.GenerateSqlDiff(
         config.Maps,
         config2.Maps,
         null,
         new Mock<ILogger>().Object,
         new[] { "Foo" },
         out warnings,
         out errors);
     Assert.Empty(script);
 }
Exemplo n.º 4
0
        public void CreateTableWorks()
        {
            var config   = new SimpleClassConfig();
            var migrator = MakeMigrator(config);
            IEnumerable <string> errors;
            IEnumerable <string> warnings;
            var script = migrator.GenerateSqlDiff(
                new IMap[] { },
                config.Maps,
                null,
                new Mock <ILogger>().Object,
                new string[0],
                out warnings,
                out errors);

            Assert.Equal(
                "create table [SimpleClasses] ([SimpleClassId] int not null identity(1,1) primary key, [Name] nvarchar(255) null, [CreatedDate] datetime not null default (current_timestamp));",
                script.Trim());
        }
Exemplo n.º 5
0
        public void NonIgnoredIndexDropped()
        {
            var migrator = MakeMigrator();
            var config   = new SimpleClassConfig();
            var config2  = new SimpleClassConfig();

            config.Maps.ElementAt(0)
            .AddIndex(new Index(config.Maps.ElementAt(0), new[] { config.Maps.ElementAt(0).Columns.First().Value }, "Foo", false));
            IEnumerable <string> warnings;
            IEnumerable <string> errors;
            var script = migrator.GenerateSqlDiff(
                config.Maps,
                config2.Maps,
                null,
                new string[0],
                new string[0],
                out warnings,
                out errors);

            Assert.Equal(@"drop index [Foo] on [SimpleClasses];", script.Trim());
        }
Exemplo n.º 6
0
        public void IgnoredIndexNotDeleted()
        {
            var migrator = MakeMigrator();
            var config   = new SimpleClassConfig();
            var config2  = new SimpleClassConfig();

            config.Maps.ElementAt(0)
            .AddIndex(new Index(config.Maps.ElementAt(0), new[] { config.Maps.ElementAt(0).Columns.First().Value }, "Foo", false));
            IEnumerable <string> warnings;
            IEnumerable <string> errors;
            var script = migrator.GenerateSqlDiff(
                config.Maps,
                config2.Maps,
                null,
                new[] { "Foo" },
                new string[0],
                out warnings,
                out errors);

            Assert.Empty(script);
        }