public void GetAutoScriptDownName()
        {
            var processor = new Mock <IMigrationProcessor>();

            processor.SetupGet(p => p.DatabaseType).Returns("SqlServer2016");
            processor.SetupGet(p => p.DatabaseTypeAliases).Returns(new[] { "SqlServer" });
            var serviceProvider = ServiceCollectionExtensions.CreateServices()
                                  .WithProcessor(processor)
                                  .AddScoped <IConnectionStringReader>(_ => new PassThroughConnectionStringReader("No connection"))
                                  .BuildServiceProvider();
            var context = serviceProvider.GetRequiredService <IMigrationContext>();
            var expr    = new AutoScriptMigrationFake();

            expr.GetDownExpressions(context);

            var expression = context.Expressions.Single();
            var processed  = (IAutoNameExpression)expression.Apply(ConventionSets.NoSchemaName);

            processed.AutoNames.ShouldNotBeNull();
            CollectionAssert.AreEqual(
                new[]
            {
                "Scripts.Down.20130508175300_AutoScriptMigrationFake_SqlServer2016.sql",
                "Scripts.Down.20130508175300_AutoScriptMigrationFake_SqlServer.sql",
                "Scripts.Down.20130508175300_AutoScriptMigrationFake_Generic.sql",
            },
                processed.AutoNames);
        }
Beispiel #2
0
        public void GetAutoScriptDownName()
        {
            var querySchema = new SqlServerProcessor(new[] { "SqlServer2016", "SqlServer" }, null, null, null, null, null);
            var context     = new MigrationContext(querySchema, null, null, null);
            var expr        = new AutoScriptMigrationFake();

            expr.GetDownExpressions(context);

            var expression = context.Expressions.Single();
            var processed  = (IAutoNameExpression)expression.Apply(ConventionSets.NoSchemaName);

            processed.AutoNames.ShouldNotBeNull();
            CollectionAssert.AreEqual(
                new[]
            {
                "Scripts.Down.20130508175300_AutoScriptMigrationFake_SqlServer2016.sql",
                "Scripts.Down.20130508175300_AutoScriptMigrationFake_SqlServer.sql",
                "Scripts.Down.20130508175300_AutoScriptMigrationFake_Generic.sql",
            },
                processed.AutoNames);
        }