Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseBuilder"/> class.
 /// </summary>
 public DatabaseBuilder(IScopeProvider scopeProvider, IGlobalSettings globalSettings, IUmbracoDatabaseFactory databaseFactory, IRuntimeState runtime, ILogger logger, IMigrationBuilder migrationBuilder, IKeyValueService keyValueService, PostMigrationCollection postMigrations)
 {
     _scopeProvider    = scopeProvider;
     _globalSettings   = globalSettings;
     _databaseFactory  = databaseFactory;
     _runtime          = runtime;
     _logger           = logger;
     _migrationBuilder = migrationBuilder;
     _keyValueService  = keyValueService;
     _postMigrations   = postMigrations;
 }
Example #2
0
        public void Executes_For_Any_Product_Name_When_Not_Specified()
        {
            var logger = Mock.Of <ILogger>();

            var changed1 = new Args {
                CountExecuted = 0
            };
            var post1 = new TestPostMigration(changed1);

            var posts = new PostMigrationCollection(new [] { post1 });

            var builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                switch (t.Name)
                {
                case "NoopMigration":
                    return(new NoopMigration());

                default:
                    throw new NotSupportedException();
                }
            });

            var database = new TestDatabase();
            var scope    = Mock.Of <IScope>();

            Mock.Get(scope)
            .Setup(x => x.Database)
            .Returns(database);

            var sqlContext    = new SqlContext(new SqlCeSyntaxProvider(), DatabaseType.SQLCe, Mock.Of <IPocoDataFactory>());
            var scopeProvider = new MigrationTests.TestScopeProvider(scope)
            {
                SqlContext = sqlContext
            };

            var u1 = new MigrationTests.TestUpgraderWithPostMigrations(
                new MigrationPlan("Test").From(string.Empty).To("done"));

            u1.Execute(scopeProvider, builder, Mock.Of <IKeyValueService>(), logger, posts);

            Assert.AreEqual(1, changed1.CountExecuted);
        }
 /// <summary>
 /// Executes.
 /// </summary>
 public void Execute(IScopeProvider scopeProvider, IMigrationBuilder migrationBuilder, IKeyValueService keyValueService, ILogger logger, PostMigrationCollection postMigrations)
 {
     _postMigrations = postMigrations;
     Execute(scopeProvider, migrationBuilder, keyValueService, logger);
 }