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:
Shannon Deminick
2013-04-15 21:36:24 +06:00
parent 0fe8ff57a1
commit 47f6401fcd
4 changed files with 13 additions and 3 deletions

View File

@@ -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();
}

View File

@@ -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)
{

View File

@@ -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;
}

View File

@@ -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();