public virtual IBootManager Initialize() { if (_isInitialized) throw new InvalidOperationException("The boot manager has already been initialized"); InitializeProfilerResolver(); _timer = DisposableTimer.DebugDuration<CoreBootManager>("Umbraco application starting", "Umbraco application startup complete"); //create database and service contexts for the app context var dbFactory = new DefaultDatabaseFactory(GlobalSettings.UmbracoConnectionName); Database.Mapper = new PetaPocoMapper(); var dbContext = new DatabaseContext(dbFactory); var serviceContext = new ServiceContext( new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy()); CreateApplicationContext(dbContext, serviceContext); InitializeApplicationEventsResolver(); InitializeResolvers(); //initialize the DatabaseContext dbContext.Initialize(); //now we need to call the initialize methods ApplicationEventsResolver.Current.ApplicationEventHandlers .ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext)); _isInitialized = true; return this; }
public override void Initialize() { InitializeFirstRunFlags(); var path = TestHelper.CurrentAssemblyDirectory; AppDomain.CurrentDomain.SetData("DataDirectory", path); _dbFactory = new Umbraco.Core.Persistence.DefaultDatabaseFactory( GetDbConnectionString(), GetDbProviderName(), Logger); //_dbFactory.ResetForTests(); base.Initialize(); using (ProfilingLogger.TraceDuration <BaseDatabaseFactoryTest>("init")) { //TODO: Somehow make this faster - takes 5s + DatabaseContext.Initialize(_dbFactory.ProviderName, _dbFactory.ConnectionString); CreateSqlCeDatabase(); InitializeDatabase(); //ensure the configuration matches the current version for tests SettingsForTests.ConfigurationStatus = UmbracoVersion.GetSemanticVersion().ToSemanticString(); } }
public override void Initialize() { InitializeFirstRunFlags(); var path = TestHelper.CurrentAssemblyDirectory; AppDomain.CurrentDomain.SetData("DataDirectory", path); var dbFactory = new DefaultDatabaseFactory( GetDbConnectionString(), GetDbProviderName()); _appContext = new ApplicationContext( //assign the db context new DatabaseContext(dbFactory), //assign the service context new ServiceContext(new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy()), //disable cache false) { IsReady = true }; base.Initialize(); DatabaseContext.Initialize(dbFactory.ProviderName, dbFactory.ConnectionString); CreateSqlCeDatabase(); InitializeDatabase(); //ensure the configuration matches the current version for tests SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3); }
public void PetaPocoConnection_Cant_Connect_To_SqlDatabase_Because_Of_Network() { // Arrange const string providerName = "System.Data.SqlClient"; const string connectionString = @"server=.\SQLEXPRESS;database=EmptyForTest;user id=umbraco;password=umbraco"; var factory = new DefaultDatabaseFactory(connectionString, providerName); var database = factory.CreateDatabase(); //Act Assert.Throws<SqlException>( () => database.Fetch<dynamic>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES")); }