updates unit test to ensure UmbracoContext.Current is nulled, updates dispose on application context to
not dispose the database if it is not configured.
This commit is contained in:
@@ -256,7 +256,7 @@ namespace Umbraco.Core
|
||||
this.ApplicationCache = null;
|
||||
if (_databaseContext != null) //need to check the internal field here
|
||||
{
|
||||
if (DatabaseContext.Database != null)
|
||||
if (DatabaseContext.IsDatabaseConfigured)
|
||||
{
|
||||
DatabaseContext.Database.Dispose();
|
||||
}
|
||||
|
||||
@@ -234,6 +234,10 @@ namespace Umbraco.Core.Sync
|
||||
{
|
||||
if (refresher == null) throw new ArgumentNullException("refresher");
|
||||
|
||||
LogHelper.Debug<DefaultServerMessenger>("Invoking refresher {0} on single server instance, message type {1}",
|
||||
() => refresher.GetType(),
|
||||
() => dispatchType);
|
||||
|
||||
//if it is a refresh all we'll do it here since ids will be null or empty
|
||||
if (dispatchType == MessageType.RefreshAll)
|
||||
{
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
get { return ApplicationContext.DatabaseContext; }
|
||||
}
|
||||
|
||||
protected UmbracoContext GetUmbracoContext(string url, int templateId, RouteData routeData = null)
|
||||
protected UmbracoContext GetUmbracoContext(string url, int templateId, RouteData routeData = null, bool setSingleton = false)
|
||||
{
|
||||
var cache = new PublishedContentCache();
|
||||
|
||||
@@ -300,6 +300,11 @@ namespace Umbraco.Tests.TestHelpers
|
||||
ApplicationContext,
|
||||
new PublishedCaches(cache, new PublishedMediaCache()));
|
||||
|
||||
if (setSingleton)
|
||||
{
|
||||
UmbracoContext.Current = ctx;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
@@ -27,7 +28,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
//reset settings
|
||||
SettingsForTests.Reset();
|
||||
|
||||
UmbracoContext.Current = null;
|
||||
TestHelper.CleanContentDirectories();
|
||||
//reset the app context, this should reset most things that require resetting like ALL resolvers
|
||||
ApplicationContext.Current.DisposeIfDisposable();
|
||||
|
||||
Reference in New Issue
Block a user