diff --git a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
index 9926e7d92a..b81675789a 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
@@ -58,10 +58,12 @@ namespace Umbraco.Tests.TestHelpers
engine.CreateDatabase();
Resolution.Freeze();
- ApplicationContext = new ApplicationContext() { IsReady = true };
- DatabaseContext = DatabaseContext.Current;
- ServiceContext = new ServiceContext(new PetaPocoUnitOfWorkProvider(), new FileUnitOfWorkProvider(), new PublishingStrategy());
-
+ ApplicationContext.Current = new ApplicationContext(
+ //assign the db context
+ new DatabaseContext(new DefaultDatabaseFactory()),
+ //assign the service context
+ new ServiceContext(new PetaPocoUnitOfWorkProvider(), new FileUnitOfWorkProvider(), new PublishingStrategy())) { IsReady = true };
+
//Configure the Database and Sql Syntax based on connection string set in config
DatabaseContext.Initialize();
//Create the umbraco database and its base data
@@ -76,10 +78,9 @@ namespace Umbraco.Tests.TestHelpers
TestHelper.CleanContentDirectories();
- //reset the app context
- DatabaseContext = null;
+ //reset the app context
+ ApplicationContext.ApplicationCache.ClearAllCache();
ApplicationContext.Current = null;
- ServiceContext = null;
Resolution.IsFrozen = false;
RepositoryResolver.Reset();
@@ -94,11 +95,20 @@ namespace Umbraco.Tests.TestHelpers
}
}
- protected ApplicationContext ApplicationContext { get; set; }
+ protected ApplicationContext ApplicationContext
+ {
+ get { return ApplicationContext.Current; }
+ }
- protected ServiceContext ServiceContext { get; set; }
+ protected ServiceContext ServiceContext
+ {
+ get { return ApplicationContext.Services; }
+ }
- protected DatabaseContext DatabaseContext { get; set; }
+ protected DatabaseContext DatabaseContext
+ {
+ get { return ApplicationContext.DatabaseContext; }
+ }
protected UmbracoContext GetUmbracoContext(string url, int templateId, RouteData routeData = null)
{
diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
index 59316bf78c..fdbe615af4 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
@@ -7,6 +7,10 @@ using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.ObjectResolution;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Persistence.UnitOfWork;
+using Umbraco.Core.Publishing;
+using Umbraco.Core.Services;
using Umbraco.Tests.Stubs;
using Umbraco.Web;
using Umbraco.Web.Routing;
@@ -32,8 +36,15 @@ namespace Umbraco.Tests.TestHelpers
Resolution.Freeze();
- ApplicationContext = new ApplicationContext { IsReady = true };
- DatabaseContext = DatabaseContext.Current;
+ //NOTE: We are not constructing with the service context here because it is not required for these tests (currently)
+ // if we do, this means that we have to initialized the RepositoryResolver too.
+ ApplicationContext.Current = new ApplicationContext
+ {
+ IsReady = true,
+ //assign the db context
+ DatabaseContext = new DatabaseContext(new DefaultDatabaseFactory())
+ };
+
}
[TearDown]
@@ -44,7 +55,6 @@ namespace Umbraco.Tests.TestHelpers
//reset the app context
ApplicationContext.ApplicationCache.ClearAllCache();
ApplicationContext.Current = null;
- DatabaseContext = null;
Resolution.IsFrozen = false;
if (RequiresDbSetup)
@@ -98,9 +108,15 @@ namespace Umbraco.Tests.TestHelpers
return factory;
}
- protected ApplicationContext ApplicationContext { get; private set; }
+ protected ApplicationContext ApplicationContext
+ {
+ get { return ApplicationContext.Current; }
+ }
- protected DatabaseContext DatabaseContext { get; private set; }
+ protected DatabaseContext DatabaseContext
+ {
+ get { return ApplicationContext.DatabaseContext; }
+ }
internal virtual IRoutesCache GetRoutesCache()
{
diff --git a/src/Umbraco.Web/Strategies/UpdateContentCache.cs b/src/Umbraco.Web/Strategies/UpdateContentCache.cs
index 4dc81a5576..c9054391d0 100644
--- a/src/Umbraco.Web/Strategies/UpdateContentCache.cs
+++ b/src/Umbraco.Web/Strategies/UpdateContentCache.cs
@@ -26,17 +26,17 @@ namespace Umbraco.Web.Strategies
public UpdateContentCache()
{
_httpContext = new HttpContextWrapper(HttpContext.Current);
- _serviceContext = ServiceContext.Current;
+ _serviceContext = ApplicationContext.Current.Services;
- PublishingStrategy.Published += PublishingStrategy_Published;
+ BasePublishingStrategy.Published += PublishingStrategy_Published;
}
public UpdateContentCache(HttpContextBase httpContext)
{
_httpContext = httpContext;
- _serviceContext = ServiceContext.Current;
+ _serviceContext = ApplicationContext.Current.Services;
- PublishingStrategy.Published += PublishingStrategy_Published;
+ BasePublishingStrategy.Published += PublishingStrategy_Published;
}
void PublishingStrategy_Published(object sender, PublishingEventArgs e)
@@ -232,7 +232,7 @@ namespace Umbraco.Web.Strategies
internal void Unsubscribe()
{
- PublishingStrategy.Published -= PublishingStrategy_Published;
+ BasePublishingStrategy.Published -= PublishingStrategy_Published;
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs
index 7c97ecce6b..ed6855b3e2 100644
--- a/src/Umbraco.Web/UmbracoContext.cs
+++ b/src/Umbraco.Web/UmbracoContext.cs
@@ -79,7 +79,7 @@ namespace Umbraco.Web
return _umbracoContext;
}
- set
+ internal set
{
lock (Locker)
{
diff --git a/src/Umbraco.Web/umbraco.presentation/install/steps/database.ascx.cs b/src/Umbraco.Web/umbraco.presentation/install/steps/database.ascx.cs
index a1049ffa92..eb1c7b2cf2 100644
--- a/src/Umbraco.Web/umbraco.presentation/install/steps/database.ascx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/install/steps/database.ascx.cs
@@ -131,15 +131,15 @@ namespace umbraco.presentation.install.steps
{
if (string.IsNullOrEmpty(ConnectionString.Text) == false)
{
- DatabaseContext.Current.ConfigureDatabaseConnection(ConnectionString.Text);
+ ApplicationContext.Current.DatabaseContext.ConfigureDatabaseConnection(ConnectionString.Text);
}
else if (IsEmbeddedDatabase)
{
- DatabaseContext.Current.ConfigureDatabaseConnection();
+ ApplicationContext.Current.DatabaseContext.ConfigureDatabaseConnection();
}
else
{
- DatabaseContext.Current.ConfigureDatabaseConnection(DatabaseServer.Text, DatabaseName.Text,
+ ApplicationContext.Current.DatabaseContext.ConfigureDatabaseConnection(DatabaseServer.Text, DatabaseName.Text,
DatabaseUsername.Text, DatabasePassword.Text,
DatabaseType.SelectedValue);
}
diff --git a/src/Umbraco.Web/umbraco.presentation/install/utills/p.aspx.cs b/src/Umbraco.Web/umbraco.presentation/install/utills/p.aspx.cs
index 4a0cf39b6d..16831c8bf9 100644
--- a/src/Umbraco.Web/umbraco.presentation/install/utills/p.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/install/utills/p.aspx.cs
@@ -58,7 +58,7 @@ namespace umbraco.presentation.install.utills
{
LogHelper.Info("Running 'installOrUpgrade' service");
- var result = DatabaseContext.Current.CreateDatabaseSchemaAndDataOrUpgrade();
+ var result = ApplicationContext.Current.DatabaseContext.CreateDatabaseSchemaAndDataOrUpgrade();
var js = new JavaScriptSerializer();
var jsonResult = js.Serialize(result);