private void RebuildSchemaFirstTime(TestDbMeta meta) { var dbFactory = _dbFactoryProvider.Create(); dbFactory.Configure(meta.ToStronglyTypedConnectionString()); using var database = (UmbracoDatabase)dbFactory.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(); }
public SqliteTestDatabase(TestDatabaseSettings settings, TestUmbracoDatabaseFactoryProvider dbFactoryProvider, ILoggerFactory loggerFactory) { _settings = settings ?? throw new ArgumentNullException(nameof(settings)); _dbFactoryProvider = dbFactoryProvider; _databaseFactory = dbFactoryProvider.Create(); _loggerFactory = loggerFactory; var schema = Enumerable.Range(0, _settings.SchemaDatabaseCount) .Select(x => CreateSqLiteMeta(false)); var empty = Enumerable.Range(0, _settings.EmptyDatabasesCount) .Select(x => CreateSqLiteMeta(true)); _testDatabases = schema.Concat(empty).ToList(); }