From 0efeba374470718ab7f408f6d4b6b91ba953bbfb Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 15 Jul 2015 16:28:50 +0200 Subject: [PATCH] Fixing unit tests, decouples more singleton accessors --- src/Umbraco.Core/ApplicationContext.cs | 18 +++++- src/Umbraco.Core/CoreBootManager.cs | 2 +- src/Umbraco.Core/StringExtensions.cs | 2 +- .../Strings/DefaultShortStringHelper.cs | 17 +++++- .../BootManagers/CoreBootManagerTests.cs | 13 +++++ src/Umbraco.Tests/Macros/MacroTests.cs | 12 ++-- .../Strings/CmsHelperCasingTests.cs | 2 +- .../Strings/DefaultShortStringHelperTests.cs | 58 +++++++++---------- .../TestHelpers/BaseUmbracoApplicationTest.cs | 2 +- .../UmbracoExamine/ExamineBaseTest.cs | 2 +- src/Umbraco.Web/umbraco.presentation/macro.cs | 6 +- 11 files changed, 85 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 4b17a6decc..5a3359c677 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -31,6 +31,7 @@ namespace Umbraco.Core if (dbContext == null) throw new ArgumentNullException("dbContext"); if (serviceContext == null) throw new ArgumentNullException("serviceContext"); if (cache == null) throw new ArgumentNullException("cache"); + if (logger == null) throw new ArgumentNullException("logger"); _databaseContext = dbContext; _services = serviceContext; ApplicationCache = cache; @@ -45,7 +46,7 @@ namespace Umbraco.Core /// /// /// - [Obsolete("Use the other constructor specifying an ILogger instead")] + [Obsolete("Use the other constructor specifying a ProfilingLogger instead")] public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache) : this(dbContext, serviceContext, cache, new ProfilingLogger(LoggerResolver.Current.Logger, ProfilerResolver.Current.Profiler)) @@ -56,10 +57,25 @@ namespace Umbraco.Core /// Creates a basic app context /// /// + [Obsolete("Use the other constructor specifying a ProfilingLogger instead")] public ApplicationContext(CacheHelper cache) { ApplicationCache = cache; + ProfilingLogger = new ProfilingLogger(LoggerResolver.Current.Logger, ProfilerResolver.Current.Profiler); + Init(); + } + /// + /// Creates a basic app context + /// + /// + /// + public ApplicationContext(CacheHelper cache, ProfilingLogger logger) + { + if (cache == null) throw new ArgumentNullException("cache"); + if (logger == null) throw new ArgumentNullException("logger"); + ApplicationCache = cache; + ProfilingLogger = logger; Init(); } diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index a6df98eef9..59bda786c9 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -457,7 +457,7 @@ namespace Umbraco.Core // use the new DefaultShortStringHelper ShortStringHelperResolver.Current = new ShortStringHelperResolver( //new LegacyShortStringHelper()); - new DefaultShortStringHelper().WithDefaultConfig()); + new DefaultShortStringHelper(UmbracoConfig.For.UmbracoSettings()).WithDefaultConfig()); UrlSegmentProviderResolver.Current = new UrlSegmentProviderResolver( ServiceProvider, LoggerResolver.Current.Logger, diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 0e32991d0d..0f2796f8da 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -948,7 +948,7 @@ namespace Umbraco.Core // as the ShortStringHelper is too important, so as long as it's not there // already, we use a default one. That should never happen, but... Logging.LogHelper.Warn("ShortStringHelperResolver.HasCurrent == false, fallback to default."); - _helper = new DefaultShortStringHelper().WithDefaultConfig(); + _helper = new DefaultShortStringHelper(UmbracoConfig.For.UmbracoSettings()).WithDefaultConfig(); _helper.Freeze(); return _helper; } diff --git a/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs b/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs index 3414389704..96b8187e22 100644 --- a/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs +++ b/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Globalization; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; namespace Umbraco.Core.Strings { @@ -18,10 +19,20 @@ namespace Umbraco.Core.Strings /// public class DefaultShortStringHelper : IShortStringHelper { + private readonly IUmbracoSettingsSection _umbracoSettings; + #region Ctor and vars + [Obsolete("Use the other ctor that specifies all dependencies")] public DefaultShortStringHelper() { + _umbracoSettings = _umbracoSettings; + InitializeLegacyUrlReplaceCharacters(); + } + + public DefaultShortStringHelper(IUmbracoSettingsSection umbracoSettings) + { + _umbracoSettings = umbracoSettings; InitializeLegacyUrlReplaceCharacters(); } @@ -57,7 +68,7 @@ namespace Umbraco.Core.Strings private void InitializeLegacyUrlReplaceCharacters() { - foreach (var node in UmbracoConfig.For.UmbracoSettings().RequestHandler.CharCollection) + foreach (var node in _umbracoSettings.RequestHandler.CharCollection) { if(string.IsNullOrEmpty(node.Char) == false) _urlReplaceCharacters[node.Char] = node.Replacement; @@ -146,7 +157,7 @@ namespace Umbraco.Core.Strings PreFilter = ApplyUrlReplaceCharacters, PostFilter = x => CutMaxLength(x, 240), IsTerm = (c, leading) => char.IsLetterOrDigit(c) || c == '_', // letter, digit or underscore - StringType = (UmbracoConfig.For.UmbracoSettings().RequestHandler.ConvertUrlsToAscii ? CleanStringType.Ascii : CleanStringType.Utf8) | CleanStringType.LowerCase, + StringType = (_umbracoSettings.RequestHandler.ConvertUrlsToAscii ? CleanStringType.Ascii : CleanStringType.Utf8) | CleanStringType.LowerCase, BreakTermsOnUpper = false, Separator = '-' }).WithConfig(CleanStringType.FileName, new Config @@ -323,7 +334,7 @@ function validateSafeAlias(input, value, immediate, callback) {{ public string GetShortStringServicesJavaScript(string controllerPath) { return string.Format(SssjsFormat, - UmbracoConfig.For.UmbracoSettings().Content.ForceSafeAliases ? "true" : "false", controllerPath); + _umbracoSettings.Content.ForceSafeAliases ? "true" : "false", controllerPath); } #endregion diff --git a/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs b/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs index 381f3889b5..226242547c 100644 --- a/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs +++ b/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs @@ -12,6 +12,7 @@ using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Tests.TestHelpers; using umbraco.interfaces; +using Umbraco.Core.Persistence; namespace Umbraco.Tests.BootManagers { @@ -36,6 +37,18 @@ namespace Umbraco.Tests.BootManagers _testApp = null; } + /// + /// Inheritors can override this if they wish to create a custom application context + /// + protected override void SetupApplicationContext() + { + base.SetupApplicationContext(); + + var dbContextMock = new Mock(Mock.Of(), Mock.Of(), Mock.Of(), "test"); + dbContextMock.Setup(x => x.CanConnect).Returns(true); + ApplicationContext.DatabaseContext = dbContextMock.Object; + } + protected override void FreezeResolution() { //don't freeze resolution, we'll do that in the boot manager diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs index 99ec1f4e81..4f0b91d4ca 100644 --- a/src/Umbraco.Tests/Macros/MacroTests.cs +++ b/src/Umbraco.Tests/Macros/MacroTests.cs @@ -11,6 +11,8 @@ using Umbraco.Core.Logging; using Umbraco.Core.Profiling; using umbraco; using umbraco.cms.businesslogic.macro; +using Umbraco.Core.Configuration; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Macros { @@ -26,18 +28,14 @@ namespace Umbraco.Tests.Macros new ObjectCacheRuntimeCacheProvider(), new StaticCacheProvider(), new NullCacheProvider()); - ApplicationContext.Current = new ApplicationContext(cacheHelper); - ProfilerResolver.Current = new ProfilerResolver(new LogProfiler(Mock.Of())) - { - CanResolveBeforeFrozen = true - }; + ApplicationContext.Current = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of(), Mock.Of())); + + UmbracoConfig.For.SetUmbracoSettings(SettingsForTests.GetDefault()); } [TearDown] public void TearDown() { - ProfilerResolver.Current.DisposeIfDisposable(); - ProfilerResolver.Reset(); ApplicationContext.Current.ApplicationCache.ClearAllCache(); ApplicationContext.Current.DisposeIfDisposable(); ApplicationContext.Current = null; diff --git a/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs b/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs index 798cc57526..0f7b4fbd41 100644 --- a/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs +++ b/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs @@ -51,7 +51,7 @@ namespace Umbraco.Tests.Strings [TestCase("WhoIsNumber6InTheVillage", "Who Is Number6 In The Village")] // issue is fixed public void CompatibleDefaultReplacement(string input, string expected) { - var helper = new DefaultShortStringHelper(); + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()); var output = input.Length < 2 ? input : helper.SplitPascalCasing(input, ' ').ToFirstUpperInvariant(); Assert.AreEqual(expected, output); } diff --git a/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs b/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs index 04b632ffeb..025e7cd613 100644 --- a/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs +++ b/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs @@ -15,14 +15,13 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Strings { [TestFixture] - public class DefaultShortStringHelperTests : BaseUmbracoConfigurationTest + public class DefaultShortStringHelperTests { private DefaultShortStringHelper _helper; [SetUp] - public override void Initialize() + public void Initialize() { - base.Initialize(); // NOTE: it is not possible to configure the helper once it has been assigned // to the resolver and resolution has frozen. but, obviously, it is possible @@ -32,7 +31,7 @@ namespace Umbraco.Tests.Strings // NOTE pre-filters runs _before_ Recode takes place // so there still may be utf8 chars even though you want ascii - _helper = new DefaultShortStringHelper() + _helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.FileName, new DefaultShortStringHelper.Config { //PreFilter = ClearFileChars, // done in IsTerm @@ -80,9 +79,8 @@ namespace Umbraco.Tests.Strings } [TearDown] - public override void TearDown() + public void TearDown() { - base.TearDown(); ShortStringHelperResolver.Reset(); } @@ -131,11 +129,11 @@ namespace Umbraco.Tests.Strings const string input = "ÆØÅ and æøå and 中文测试 and אודות האתר and größer БбДдЖж page"; - var helper = new DefaultShortStringHelper().WithDefaultConfig(); // unicode + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()).WithDefaultConfig(); // unicode var output = helper.CleanStringForUrlSegment(input); Assert.AreEqual("æøå-and-æøå-and-中文测试-and-אודות-האתר-and-größer-ббдджж-page", output); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.UrlSegment, new DefaultShortStringHelper.Config { IsTerm = (c, leading) => char.IsLetterOrDigit(c) || c == '_', @@ -149,7 +147,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringUnderscoreInTerm() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { // underscore is accepted within terms @@ -159,7 +157,7 @@ namespace Umbraco.Tests.Strings }); Assert.AreEqual("foo_bar*nil", helper.CleanString("foo_bar nil", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { // underscore is not accepted within terms @@ -173,7 +171,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringLeadingChars() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { // letters and digits are valid leading chars @@ -183,7 +181,7 @@ namespace Umbraco.Tests.Strings }); Assert.AreEqual("0123foo*bar*543*nil*321", helper.CleanString("0123foo_bar 543 nil 321", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { // only letters are valid leading chars @@ -194,14 +192,14 @@ namespace Umbraco.Tests.Strings Assert.AreEqual("foo*bar*543*nil*321", helper.CleanString("0123foo_bar 543 nil 321", CleanStringType.Alias)); Assert.AreEqual("foo*bar*543*nil*321", helper.CleanString("0123 foo_bar 543 nil 321", CleanStringType.Alias)); - helper = new DefaultShortStringHelper().WithDefaultConfig(); + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()).WithDefaultConfig(); Assert.AreEqual("child2", helper.CleanStringForSafeAlias("1child2")); } [Test] public void CleanStringTermOnUpper() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -211,7 +209,7 @@ namespace Umbraco.Tests.Strings }); Assert.AreEqual("foo*Bar", helper.CleanString("fooBar", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -225,7 +223,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringAcronymOnNonUpper() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -238,7 +236,7 @@ namespace Umbraco.Tests.Strings Assert.AreEqual("foo*BAnil", helper.CleanString("foo BAnil", CleanStringType.Alias)); Assert.AreEqual("foo*Bnil", helper.CleanString("foo Bnil", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -255,7 +253,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringGreedyAcronyms() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -268,7 +266,7 @@ namespace Umbraco.Tests.Strings Assert.AreEqual("foo*BA*nil", helper.CleanString("foo BAnil", CleanStringType.Alias)); Assert.AreEqual("foo*Bnil", helper.CleanString("foo Bnil", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -285,7 +283,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringWhiteSpace() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -298,7 +296,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringSeparator() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -306,7 +304,7 @@ namespace Umbraco.Tests.Strings }); Assert.AreEqual("foo*bar", helper.CleanString("foo bar", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -314,14 +312,14 @@ namespace Umbraco.Tests.Strings }); Assert.AreEqual("foo bar", helper.CleanString("foo bar", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged }); Assert.AreEqual("foobar", helper.CleanString("foo bar", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -333,7 +331,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringSymbols() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -387,7 +385,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringEncoding() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -396,7 +394,7 @@ namespace Umbraco.Tests.Strings Assert.AreEqual("中文测试", helper.CleanString("中文测试", CleanStringType.Alias)); Assert.AreEqual("léger*中文测试*ZÔRG", helper.CleanString("léger 中文测试 ZÔRG", CleanStringType.Alias)); - helper = new DefaultShortStringHelper() + helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Ascii | CleanStringType.Unchanged, @@ -415,7 +413,7 @@ namespace Umbraco.Tests.Strings contentMock.Setup(x => x.ConvertUrlsToAscii).Returns(false); SettingsForTests.ConfigureSettings(settings); - var helper = new DefaultShortStringHelper().WithDefaultConfig(); + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()).WithDefaultConfig(); const string input = "0123 中文测试 中文测试 léger ZÔRG (2) a?? *x"; @@ -436,7 +434,7 @@ namespace Umbraco.Tests.Strings [Test] public void CleanStringCasing() { - var helper = new DefaultShortStringHelper() + var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config { StringType = CleanStringType.Utf8 | CleanStringType.Unchanged, @@ -539,7 +537,7 @@ namespace Umbraco.Tests.Strings //#endregion //public void CleanStringWithUnderscore(string input, string expected, bool allowUnderscoreInTerm) //{ - // var helper = new DefaultShortStringHelper() + // var helper = new DefaultShortStringHelper(SettingsForTests.GetDefault()) // .WithConfig(allowUnderscoreInTerm: allowUnderscoreInTerm); // var output = helper.CleanString(input, CleanStringType.Alias | CleanStringType.Ascii | CleanStringType.CamelCase); // Assert.AreEqual(expected, output); diff --git a/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs b/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs index 12914c8ecd..23c3391e84 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs @@ -71,7 +71,7 @@ namespace Umbraco.Tests.TestHelpers TestHelper.CleanContentDirectories(); TestHelper.CleanUmbracoSettingsConfig(); //reset the app context, this should reset most things that require resetting like ALL resolvers - ObjectExtensions.DisposeIfDisposable(ApplicationContext.Current); + ApplicationContext.Current.DisposeIfDisposable(); ApplicationContext.Current = null; ResetPluginManager(); diff --git a/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs b/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs index d36e49bc25..5fed998194 100644 --- a/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs @@ -15,7 +15,7 @@ namespace Umbraco.Tests.UmbracoExamine { UmbracoExamineSearcher.DisableInitializationCheck = true; BaseUmbracoIndexer.DisableInitializationCheck = true; - ShortStringHelperResolver.Current = new ShortStringHelperResolver(new DefaultShortStringHelper()); + ShortStringHelperResolver.Current = new ShortStringHelperResolver(new DefaultShortStringHelper(SettingsForTests.GetDefault())); Resolution.Freeze(); } diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs index 136c30c799..53bdaaa9de 100644 --- a/src/Umbraco.Web/umbraco.presentation/macro.cs +++ b/src/Umbraco.Web/umbraco.presentation/macro.cs @@ -1578,7 +1578,7 @@ namespace umbraco //Trace out to profiling... doesn't actually profile, just for informational output. if (excludeProfiling == false) { - using (ProfilerResolver.Current.Profiler.Step(string.Format("{0}", message))) + using (ApplicationContext.Current.ProfilingLogger.TraceDuration(string.Format("{0}", message))) { } } @@ -1592,7 +1592,7 @@ namespace umbraco //Trace out to profiling... doesn't actually profile, just for informational output. if (excludeProfiling == false) { - using (ProfilerResolver.Current.Profiler.Step(string.Format("Warning: {0}", message))) + using (ApplicationContext.Current.ProfilingLogger.TraceDuration(string.Format("Warning: {0}", message))) { } } @@ -1606,7 +1606,7 @@ namespace umbraco //Trace out to profiling... doesn't actually profile, just for informational output. if (excludeProfiling == false) { - using (ProfilerResolver.Current.Profiler.Step(string.Format("{0}, Error: {1}", message, ex))) + using (ApplicationContext.Current.ProfilingLogger.TraceDuration(string.Format("{0}, Error: {1}", message, ex))) { } }