From 47f6401fcd07770ebd9f5efd0fb0545e85813777 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Mon, 15 Apr 2013 21:36:24 +0600 Subject: [PATCH] updates unit test to ensure UmbracoContext.Current is nulled, updates dispose on application context to not dispose the database if it is not configured. --- src/Umbraco.Core/ApplicationContext.cs | 2 +- src/Umbraco.Core/Sync/DefaultServerMessenger.cs | 4 ++++ src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs | 7 ++++++- .../TestHelpers/BaseUmbracoApplicationTest.cs | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 82500ae2d4..815e69acb4 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -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(); } diff --git a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs index a6d95faf3d..58d9cea29d 100644 --- a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs @@ -234,6 +234,10 @@ namespace Umbraco.Core.Sync { if (refresher == null) throw new ArgumentNullException("refresher"); + LogHelper.Debug("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) { diff --git a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs index 3c9db54741..c1cfcf2947 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs @@ -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; } diff --git a/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs b/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs index 1979df306c..c297150f4b 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs @@ -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();