Esempio n. 1
0
    private void RebuildSchemaFirstTime(TestDbMeta meta)
    {
        _databaseFactory.Configure(meta.ToStronglyTypedConnectionString());

        using (var database = (UmbracoDatabase)_databaseFactory.CreateDatabase())
        {
            database.LogCommands = true;

            using (NPoco.ITransaction transaction = database.GetTransaction())
            {
                var options = new TestOptionsMonitor <InstallDefaultDataSettings>(new InstallDefaultDataSettings {
                    InstallData = InstallDefaultDataOption.All
                });

                var schemaCreator = new DatabaseSchemaCreator(
                    database,
                    _loggerFactory.CreateLogger <DatabaseSchemaCreator>(), _loggerFactory,
                    new UmbracoVersion(),
                    Mock.Of <IEventAggregator>(),
                    options);

                schemaCreator.InitializeDatabaseSchema();

                transaction.Complete();

                _cachedDatabaseInitCommands = database.Commands
                                              .Where(x => !x.Text.StartsWith("SELECT ", StringComparison.OrdinalIgnoreCase))
                                              .ToArray();
            }
        }
    }
Esempio n. 2
0
        private void RebuildSchemaFirstTime(TestDbMeta meta)
        {
            _databaseFactory.Configure(meta.ConnectionString, Constants.DatabaseProviders.SqlServer);

            using (var database = (UmbracoDatabase)_databaseFactory.CreateDatabase())
            {
                database.LogCommands = true;

                using (NPoco.ITransaction transaction = database.GetTransaction())
                {
                    var schemaCreator = new DatabaseSchemaCreator(database, _loggerFactory.CreateLogger <DatabaseSchemaCreator>(), _loggerFactory, new UmbracoVersion(), Mock.Of <IEventAggregator>());
                    schemaCreator.InitializeDatabaseSchema();

                    transaction.Complete();

                    _cachedDatabaseInitCommands = database.Commands.ToArray();
                }
            }
        }