Beispiel #1
0
        private void Configure(bool installMissingDatabase)
        {
            _databaseFactory.Configure(_connectionStrings.CurrentValue);

            if (installMissingDatabase)
            {
                CreateDatabase();
            }
        }
        private void ConfigureTestDatabaseFactory(TestDbMeta meta, IUmbracoDatabaseFactory factory, IRuntimeState state)
        {
            ILogger <UmbracoIntegrationTest> log = Services.GetRequiredService <ILogger <UmbracoIntegrationTest> >();

            log.LogInformation($"ConfigureTestDatabaseFactory - Using test database: [{meta.Name}] - IsEmpty: [{meta.IsEmpty}]");

            // It's just been pulled from container and wasn't used to create test database
            Assert.IsFalse(factory.Configured);

            factory.Configure(meta.ConnectionString, Constants.DatabaseProviders.SqlServer);
            state.DetermineRuntimeLevel();
            log.LogInformation($"ConfigureTestDatabaseFactory - Determined RuntimeLevel: [{state.Level}]");
        }
Beispiel #3
0
        private void Configure(string connectionString, string?providerName, bool installMissingDatabase)
        {
            // Update existing connection string
            var umbracoConnectionString = _connectionStrings.Get(Core.Constants.System.UmbracoConnectionName);

            umbracoConnectionString.ConnectionString = connectionString;
            umbracoConnectionString.ProviderName     = providerName;

            _databaseFactory.Configure(umbracoConnectionString);

            if (installMissingDatabase)
            {
                CreateDatabase();
            }
        }
Beispiel #4
0
        private static void ConfigureEmbeddedDatabaseConnection(IUmbracoDatabaseFactory factory, ILogger logger)
        {
            SaveConnectionString(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe, logger);

            var path = Path.Combine(IOHelper.GetRootDirectorySafe(), "App_Data", "Umbraco.sdf");

            if (File.Exists(path) == false)
            {
                // this should probably be in a "using (new SqlCeEngine)" clause but not sure
                // of the side effects and it's been like this for quite some time now

                var engine = new SqlCeEngine(EmbeddedDatabaseConnectionString);
                engine.CreateDatabase();
            }

            factory.Configure(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe);
        }
Beispiel #5
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();
                }
            }
        }