From c486444edaf8b305d32bda6c4d467fd2fe3c54f8 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 12 Mar 2020 15:30:22 +0100 Subject: [PATCH] Cleaned up config for Content settings --- src/Umbraco.Configuration/ConfigsFactory.cs | 5 +- .../Implementations/ContentSettings.cs | 22 ++++++ .../UmbracoSettings/ContentElement.cs | 24 +++--- .../UmbracoSettings/UmbracoSettingsSection.cs | 4 +- .../Configuration/ConfigsExtensions.cs | 4 +- .../ContentSectionExtensions.cs | 16 ++-- ...IContentSection.cs => IContentSettings.cs} | 2 +- .../IUmbracoSettingsSection.cs | 9 --- src/Umbraco.Core/Templates/HtmlUrlParser.cs | 8 +- .../CompositionExtensions/Configuration.cs | 22 ------ .../EmailNotificationMethod.cs | 8 +- .../Media/UploadAutoFillProperties.cs | 10 +-- .../Models/Mapping/DataTypeMapDefinition.cs | 9 +-- .../Models/MediaExtensions.cs | 4 +- .../FileUploadPropertyEditor.cs | 16 ++-- .../FileUploadPropertyValueEditor.cs | 8 +- .../ImageCropperPropertyEditor.cs | 8 +- .../ImageCropperPropertyValueEditor.cs | 8 +- .../UploadFileTypeValidator.cs | 12 +-- .../Routing/ContentFinderByConfigured404.cs | 8 +- .../Runtime/CoreInitialComposer.cs | 1 - .../Runtime/CoreRuntime.cs | 4 +- src/Umbraco.Infrastructure/RuntimeState.cs | 4 +- .../Services/Implement/NotificationService.cs | 14 ++-- .../PublishedContentCacheTests.cs | 1 - .../ContentElementDefaultTests.cs | 22 +++--- .../UmbracoSettings/ContentElementTests.cs | 78 +++++++++---------- .../UmbracoSettings/UmbracoSettingsTests.cs | 3 +- src/Umbraco.Tests/IO/FileSystemsTests.cs | 6 +- .../Models/ContentExtensionsTests.cs | 2 +- src/Umbraco.Tests/Models/ContentTests.cs | 2 +- .../Mapping/ContentWebModelMappingTests.cs | 2 +- src/Umbraco.Tests/Models/MediaXmlTest.cs | 7 +- src/Umbraco.Tests/Models/VariationTests.cs | 2 +- .../PropertyEditors/ImageCropperTest.cs | 4 +- .../PublishedContent/NuCacheChildrenTests.cs | 2 +- .../PublishedContent/NuCacheTests.cs | 2 +- .../Routing/MediaUrlProviderTests.cs | 8 +- .../Routing/UmbracoModuleTests.cs | 2 +- src/Umbraco.Tests/Routing/UrlProviderTests.cs | 2 +- .../Runtimes/CoreRuntimeTests.cs | 4 +- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 4 +- .../Scoping/ScopeEventDispatcherTests.cs | 2 +- .../Scoping/ScopedNuCacheTests.cs | 2 +- src/Umbraco.Tests/Scoping/ScopedXmlTests.cs | 2 +- .../TestHelpers/SettingsForTests.cs | 32 ++------ src/Umbraco.Tests/TestHelpers/TestHelper.cs | 1 - .../TestHelpers/TestObjects-Mocks.cs | 11 --- src/Umbraco.Tests/TestHelpers/TestObjects.cs | 4 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 6 +- .../Web/Controllers/UsersControllerTests.cs | 8 +- .../Web/Mvc/UmbracoViewPageTests.cs | 8 +- .../Umbraco/Views/AuthorizeUpgrade.cshtml | 2 +- .../Umbraco/Views/Default.cshtml | 2 +- .../Editors/BackOfficeController.cs | 14 ++-- src/Umbraco.Web/Editors/BackOfficeModel.cs | 6 +- .../Editors/BackOfficePreviewModel.cs | 4 +- .../Editors/BackOfficeServerVariables.cs | 14 ++-- .../Editors/CurrentUserController.cs | 8 +- src/Umbraco.Web/Editors/DataTypeController.cs | 8 +- src/Umbraco.Web/Editors/ImagesController.cs | 8 +- src/Umbraco.Web/Editors/MediaController.cs | 10 +-- src/Umbraco.Web/Editors/PreviewController.cs | 8 +- src/Umbraco.Web/Editors/TinyMceController.cs | 8 +- src/Umbraco.Web/Editors/UsersController.cs | 12 +-- .../HtmlHelperBackOfficeExtensions.cs | 4 +- src/Umbraco.Web/HtmlHelperRenderExtensions.cs | 4 +- src/Umbraco.Web/Macros/MacroRenderer.cs | 8 +- .../Models/Mapping/MediaMapDefinition.cs | 8 +- .../Mvc/UmbracoViewPageOfTModel.cs | 10 +-- .../Security/AppBuilderExtensions.cs | 7 +- .../Security/BackOfficeUserManager.cs | 22 +++--- src/Umbraco.Web/UmbracoDefaultOwinStartup.cs | 4 +- 73 files changed, 279 insertions(+), 351 deletions(-) create mode 100644 src/Umbraco.Configuration/Implementations/ContentSettings.cs rename src/Umbraco.Core/Configuration/UmbracoSettings/{IContentSection.cs => IContentSettings.cs} (93%) delete mode 100644 src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs delete mode 100644 src/Umbraco.Infrastructure/Composing/CompositionExtensions/Configuration.cs diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs index d9305e0ee8..8650cc585e 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Configuration/ConfigsFactory.cs @@ -27,8 +27,7 @@ namespace Umbraco.Core.Configuration public ISecuritySettings SecuritySettings { get; } = new SecuritySettings(); public IUserPasswordConfiguration UserPasswordConfigurationSettings { get; } = new UserPasswordConfigurationSettings(); public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings(); - - public IUmbracoSettingsSection UmbracoSettings { get; } + public IContentSettings ContentSettings { get; } = new ContentSettings(); public Configs Create(IIOHelper ioHelper) { @@ -36,7 +35,6 @@ namespace Umbraco.Core.Configuration configs.Add(() => new GlobalSettings(ioHelper)); configs.Add(() => HostingSettings); - configs.Add("umbracoConfiguration/settings"); configs.Add("umbracoConfiguration/HealthChecks"); configs.Add(() => CoreDebug); @@ -60,6 +58,7 @@ namespace Umbraco.Core.Configuration configs.Add(() => SecuritySettings); configs.Add(() => UserPasswordConfigurationSettings); configs.Add(() => MemberPasswordConfigurationSettings); + configs.Add(() => ContentSettings); configs.AddCoreConfigs(ioHelper); return configs; diff --git a/src/Umbraco.Configuration/Implementations/ContentSettings.cs b/src/Umbraco.Configuration/Implementations/ContentSettings.cs new file mode 100644 index 0000000000..1c3f543bfe --- /dev/null +++ b/src/Umbraco.Configuration/Implementations/ContentSettings.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.Macros; + +namespace Umbraco.Configuration.Implementations +{ + internal class ContentSettings : ConfigurationManagerConfigBase, IContentSettings + { + public string NotificationEmailAddress => UmbracoSettingsSection.Content.Notifications.NotificationEmailAddress; + public bool DisableHtmlEmail => UmbracoSettingsSection.Content.Notifications.DisableHtmlEmail; + public IEnumerable ImageFileTypes => UmbracoSettingsSection.Content.Imaging.ImageFileTypes; + public IEnumerable ImageAutoFillProperties => UmbracoSettingsSection.Content.Imaging.ImageAutoFillProperties; + public bool ResolveUrlsFromTextString => UmbracoSettingsSection.Content.ResolveUrlsFromTextString; + public IEnumerable Error404Collection => UmbracoSettingsSection.Content.Error404Collection; + public string PreviewBadge => UmbracoSettingsSection.Content.PreviewBadge; + public MacroErrorBehaviour MacroErrorBehaviour => UmbracoSettingsSection.Content.MacroErrors; + public IEnumerable DisallowedUploadFiles => UmbracoSettingsSection.Content.DisallowedUploadFiles; + public IEnumerable AllowedUploadFiles => UmbracoSettingsSection.Content.AllowedUploadFiles; + public bool ShowDeprecatedPropertyEditors => UmbracoSettingsSection.Content.ShowDeprecatedPropertyEditors; + public string LoginBackgroundImage => UmbracoSettingsSection.Content.LoginBackgroundImage; + } +} diff --git a/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs index 8e4f0edd8f..28b4314c9a 100644 --- a/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs @@ -4,7 +4,7 @@ using Umbraco.Core.Macros; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ContentElement : UmbracoConfigurationElement, IContentSection + internal class ContentElement : UmbracoConfigurationElement, IContentSettings { private const string DefaultPreviewBadge = @"
Preview modeClick to end
"; @@ -40,26 +40,26 @@ namespace Umbraco.Core.Configuration.UmbracoSettings [ConfigurationProperty("loginBackgroundImage")] internal InnerTextConfigurationElement LoginBackgroundImage => GetOptionalTextElement("loginBackgroundImage", string.Empty); - string IContentSection.NotificationEmailAddress => Notifications.NotificationEmailAddress; + string IContentSettings.NotificationEmailAddress => Notifications.NotificationEmailAddress; - bool IContentSection.DisableHtmlEmail => Notifications.DisableHtmlEmail; + bool IContentSettings.DisableHtmlEmail => Notifications.DisableHtmlEmail; - IEnumerable IContentSection.ImageFileTypes => Imaging.ImageFileTypes; + IEnumerable IContentSettings.ImageFileTypes => Imaging.ImageFileTypes; - IEnumerable IContentSection.ImageAutoFillProperties => Imaging.ImageAutoFillProperties; + IEnumerable IContentSettings.ImageAutoFillProperties => Imaging.ImageAutoFillProperties; - bool IContentSection.ResolveUrlsFromTextString => ResolveUrlsFromTextString; + bool IContentSettings.ResolveUrlsFromTextString => ResolveUrlsFromTextString; - string IContentSection.PreviewBadge => PreviewBadge; + string IContentSettings.PreviewBadge => PreviewBadge; - MacroErrorBehaviour IContentSection.MacroErrorBehaviour => MacroErrors; + MacroErrorBehaviour IContentSettings.MacroErrorBehaviour => MacroErrors; - IEnumerable IContentSection.DisallowedUploadFiles => DisallowedUploadFiles; + IEnumerable IContentSettings.DisallowedUploadFiles => DisallowedUploadFiles; - IEnumerable IContentSection.AllowedUploadFiles => AllowedUploadFiles; + IEnumerable IContentSettings.AllowedUploadFiles => AllowedUploadFiles; - bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors; + bool IContentSettings.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors; - string IContentSection.LoginBackgroundImage => LoginBackgroundImage; + string IContentSettings.LoginBackgroundImage => LoginBackgroundImage; } } diff --git a/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs index 4860d3138e..781d00b979 100644 --- a/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection + internal class UmbracoSettingsSection : ConfigurationSection { [ConfigurationProperty("backOffice")] public BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"]; @@ -24,7 +24,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings [ConfigurationProperty("keepAlive")] internal KeepAliveElement KeepAlive => (KeepAliveElement)this["keepAlive"]; - - IContentSection IUmbracoSettingsSection.Content => Content; } } diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs index 6d4c8e1b91..93586b550b 100644 --- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs +++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs @@ -25,8 +25,8 @@ namespace Umbraco.Core public static IConnectionStrings ConnectionStrings(this Configs configs) => configs.GetConfig(); - public static IUmbracoSettingsSection Settings(this Configs configs) - => configs.GetConfig(); + public static IContentSettings Content(this Configs configs) + => configs.GetConfig(); public static ISecuritySettings Security(this Configs configs) => configs.GetConfig(); diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs index 82cc5928cf..d100eb0a74 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings /// The file extension. /// /// A value indicating whether the file extension corresponds to an image. - public static bool IsImageFile(this IContentSection contentConfig, string extension) + public static bool IsImageFile(this IContentSettings contentConfig, string extension) { if (contentConfig == null) throw new ArgumentNullException(nameof(contentConfig)); if (extension == null) return false; @@ -24,22 +24,22 @@ namespace Umbraco.Core.Configuration.UmbracoSettings /// held in settings. /// Allow upload if extension is whitelisted OR if there is no whitelist and extension is NOT blacklisted. /// - public static bool IsFileAllowedForUpload(this IContentSection contentSection, string extension) + public static bool IsFileAllowedForUpload(this IContentSettings contentSettings, string extension) { - return contentSection.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) || - (contentSection.AllowedUploadFiles.Any() == false && - contentSection.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false); + return contentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) || + (contentSettings.AllowedUploadFiles.Any() == false && + contentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false); } /// /// Gets the auto-fill configuration for a specified property alias. /// - /// + /// /// The property type alias. /// The auto-fill configuration for the specified property alias, or null. - public static IImagingAutoFillUploadField GetConfig(this IContentSection contentSection, string propertyTypeAlias) + public static IImagingAutoFillUploadField GetConfig(this IContentSettings contentSettings, string propertyTypeAlias) { - var autoFillConfigs = contentSection.ImageAutoFillProperties; + var autoFillConfigs = contentSettings.ImageAutoFillProperties; return autoFillConfigs?.FirstOrDefault(x => x.Alias == propertyTypeAlias); } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSettings.cs similarity index 93% rename from src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs rename to src/Umbraco.Core/Configuration/UmbracoSettings/IContentSettings.cs index 228b0923dc..08f6231309 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSettings.cs @@ -3,7 +3,7 @@ using Umbraco.Core.Macros; namespace Umbraco.Core.Configuration.UmbracoSettings { - public interface IContentSection : IUmbracoConfigurationSection + public interface IContentSettings : IUmbracoConfigurationSection { string NotificationEmailAddress { get; } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs deleted file mode 100644 index 3db70e6d42..0000000000 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Umbraco.Core.Configuration.UmbracoSettings -{ - public interface IUmbracoSettingsSection : IUmbracoConfigurationSection - { - IContentSection Content { get; } - } -} diff --git a/src/Umbraco.Core/Templates/HtmlUrlParser.cs b/src/Umbraco.Core/Templates/HtmlUrlParser.cs index a2fdb93292..566fce8b87 100644 --- a/src/Umbraco.Core/Templates/HtmlUrlParser.cs +++ b/src/Umbraco.Core/Templates/HtmlUrlParser.cs @@ -7,16 +7,16 @@ namespace Umbraco.Web.Templates { public sealed class HtmlUrlParser { - private readonly IContentSection _contentSection; + private readonly IContentSettings _contentSettings; private readonly IIOHelper _ioHelper; private readonly IProfilingLogger _logger; private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); - public HtmlUrlParser(IContentSection contentSection, IProfilingLogger logger, IIOHelper ioHelper) + public HtmlUrlParser(IContentSettings contentSettings, IProfilingLogger logger, IIOHelper ioHelper) { - _contentSection = contentSection; + _contentSettings = contentSettings; _ioHelper = ioHelper; _logger = logger; } @@ -32,7 +32,7 @@ namespace Umbraco.Web.Templates /// public string EnsureUrls(string text) { - if (_contentSection.ResolveUrlsFromTextString == false) return text; + if (_contentSettings.ResolveUrlsFromTextString == false) return text; using (var timer = _logger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete")) { diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Configuration.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Configuration.cs deleted file mode 100644 index e1bc079432..0000000000 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Configuration.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Umbraco.Core.Configuration; -using Umbraco.Configuration; -using Umbraco.Core.Configuration.UmbracoSettings; - -namespace Umbraco.Core.Composing.CompositionExtensions -{ - /// - /// Compose configurations. - /// - internal static class Configuration - { - public static Composition ComposeConfiguration(this Composition composition) - { - // common configurations are already registered - // register others - - composition.RegisterUnique(factory => factory.GetInstance().Content); - - return composition; - } - } -} diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index b27113a0f1..f76a69c0fa 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -18,9 +18,9 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods private readonly IRuntimeState _runtimeState; private readonly ILogger _logger; private readonly IGlobalSettings _globalSettings; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; + private readonly IContentSettings _contentSettings; - public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IUmbracoSettingsSection umbracoSettingsSection) : base(healthChecks) + public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IContentSettings contentSettings) : base(healthChecks) { var recipientEmail = Settings["recipientEmail"]?.Value; if (string.IsNullOrWhiteSpace(recipientEmail)) @@ -35,7 +35,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods _runtimeState = runtimeState; _logger = logger; _globalSettings = globalSettings; - _umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection)); + _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); } public string RecipientEmail { get; } @@ -74,7 +74,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods private MailMessage CreateMailMessage(string subject, string message) { - var to = _umbracoSettingsSection.Content.NotificationEmailAddress; + var to = _contentSettings.NotificationEmailAddress; if (string.IsNullOrWhiteSpace(subject)) subject = "Umbraco Health Check Status"; diff --git a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs index 4c02111ccd..665693d91f 100644 --- a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs +++ b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs @@ -17,13 +17,13 @@ namespace Umbraco.Web.Media { private readonly IMediaFileSystem _mediaFileSystem; private readonly ILogger _logger; - private readonly IContentSection _contentSection; + private readonly IContentSettings _contentSettings; - public UploadAutoFillProperties(IMediaFileSystem mediaFileSystem, ILogger logger, IContentSection contentSection) + public UploadAutoFillProperties(IMediaFileSystem mediaFileSystem, ILogger logger, IContentSettings contentSettings) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _contentSection = contentSection ?? throw new ArgumentNullException(nameof(contentSection)); + _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); } /// @@ -68,7 +68,7 @@ namespace Umbraco.Web.Media using (var filestream = _mediaFileSystem.OpenFile(filepath)) { var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.'); - var size = _contentSection.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null; + var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null; SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment); } } @@ -102,7 +102,7 @@ namespace Umbraco.Web.Media else { var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.'); - var size = _contentSection.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null; + var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null; SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment); } } diff --git a/src/Umbraco.Infrastructure/Models/Mapping/DataTypeMapDefinition.cs b/src/Umbraco.Infrastructure/Models/Mapping/DataTypeMapDefinition.cs index d57809c844..0bd6d54c08 100644 --- a/src/Umbraco.Infrastructure/Models/Mapping/DataTypeMapDefinition.cs +++ b/src/Umbraco.Infrastructure/Models/Mapping/DataTypeMapDefinition.cs @@ -15,13 +15,13 @@ namespace Umbraco.Web.Models.Mapping { private readonly PropertyEditorCollection _propertyEditors; private readonly ILogger _logger; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; + private readonly IContentSettings _contentSettings; - public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IUmbracoSettingsSection umbracoSettingsSection) + public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IContentSettings contentSettings) { _propertyEditors = propertyEditors; _logger = logger; - _umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection)); + _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); } private static readonly int[] SystemIds = @@ -128,9 +128,8 @@ namespace Umbraco.Web.Models.Mapping private IEnumerable MapAvailableEditors(IDataType source, MapperContext context) { - var contentSection = _umbracoSettingsSection.Content; var properties = _propertyEditors - .Where(x => !x.IsDeprecated || contentSection.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias) + .Where(x => !x.IsDeprecated || _contentSettings.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias) .OrderBy(x => x.Name); return context.MapEnumerable(properties); } diff --git a/src/Umbraco.Infrastructure/Models/MediaExtensions.cs b/src/Umbraco.Infrastructure/Models/MediaExtensions.cs index 41bcfdbc88..ffcc2c2a92 100644 --- a/src/Umbraco.Infrastructure/Models/MediaExtensions.cs +++ b/src/Umbraco.Infrastructure/Models/MediaExtensions.cs @@ -27,9 +27,9 @@ namespace Umbraco.Core.Models /// /// Gets the urls of a media item. /// - public static string[] GetUrls(this IMedia media, IContentSection contentSection, MediaUrlGeneratorCollection mediaUrlGenerators) + public static string[] GetUrls(this IMedia media, IContentSettings contentSettings, MediaUrlGeneratorCollection mediaUrlGenerators) { - return contentSection.ImageAutoFillProperties + return contentSettings.ImageAutoFillProperties .Select(field => media.GetUrl(field.Alias, mediaUrlGenerators)) .Where(link => string.IsNullOrWhiteSpace(link) == false) .ToArray(); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs index 8c820c497c..698fcb10b3 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs @@ -22,23 +22,21 @@ namespace Umbraco.Web.PropertyEditors public class FileUploadPropertyEditor : DataEditor, IMediaUrlGenerator { private readonly IMediaFileSystem _mediaFileSystem; - private readonly IContentSection _contentSection; + private readonly IContentSettings _contentSettings; private readonly UploadAutoFillProperties _uploadAutoFillProperties; private readonly IDataTypeService _dataTypeService; private readonly ILocalizationService _localizationService; private readonly ILocalizedTextService _localizedTextService; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; - public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSection, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection) + public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) : base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); - _contentSection = contentSection; + _contentSettings = contentSettings; _dataTypeService = dataTypeService; _localizationService = localizationService; _localizedTextService = localizedTextService; - _uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSection); - _umbracoSettingsSection = umbracoSettingsSection; + _uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings); } /// @@ -47,8 +45,8 @@ namespace Umbraco.Web.PropertyEditors /// The corresponding property value editor. protected override IDataValueEditor CreateValueEditor() { - var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _umbracoSettingsSection); - editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _umbracoSettingsSection)); + var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _contentSettings); + editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _contentSettings)); return editor; } @@ -179,7 +177,7 @@ namespace Umbraco.Web.PropertyEditors foreach (var property in properties) { - var autoFillConfig = _contentSection.GetConfig(property.Alias); + var autoFillConfig = _contentSettings.GetConfig(property.Alias); if (autoFillConfig == null) continue; foreach (var pvalue in property.Values) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs index 97b5ef20f5..e45896551c 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -16,13 +16,13 @@ namespace Umbraco.Web.PropertyEditors internal class FileUploadPropertyValueEditor : DataValueEditor { private readonly IMediaFileSystem _mediaFileSystem; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; + private readonly IContentSettings _contentSettings; - public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection) + public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IContentSettings contentSettings) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); - _umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection)); + _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); } /// @@ -101,7 +101,7 @@ namespace Umbraco.Web.PropertyEditors { // process the file // no file, invalid file, reject change - if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _umbracoSettingsSection) == false) + if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _contentSettings) == false) return null; // get the filepath diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs index 045a0fb3d2..586a120609 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs @@ -29,17 +29,16 @@ namespace Umbraco.Web.PropertyEditors public class ImageCropperPropertyEditor : DataEditor, IMediaUrlGenerator { private readonly IMediaFileSystem _mediaFileSystem; - private readonly IContentSection _contentSettings; + private readonly IContentSettings _contentSettings; private readonly IDataTypeService _dataTypeService; private readonly ILocalizationService _localizationService; private readonly IIOHelper _ioHelper; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; private readonly UploadAutoFillProperties _autoFillProperties; /// /// Initializes a new instance of the class. /// - public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, IUmbracoSettingsSection umbracoSettingsSection) + public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) : base(logger, dataTypeService, localizationService, localizedTextService,shortStringHelper) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); @@ -47,7 +46,6 @@ namespace Umbraco.Web.PropertyEditors _dataTypeService = dataTypeService; _localizationService = localizationService; _ioHelper = ioHelper; - _umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection)); // TODO: inject? _autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, _contentSettings); @@ -68,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors /// Creates the corresponding property value editor. /// /// The corresponding property value editor. - protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _umbracoSettingsSection); + protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings); /// /// Creates the corresponding preValue editor. diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs index 9919dda47d..1c7c8b922a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs @@ -22,14 +22,14 @@ namespace Umbraco.Web.PropertyEditors { private readonly ILogger _logger; private readonly IMediaFileSystem _mediaFileSystem; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; + private readonly IContentSettings _contentSettings; - public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection) + public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IContentSettings contentSettings) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); - _umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection)); + _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); } /// @@ -146,7 +146,7 @@ namespace Umbraco.Web.PropertyEditors { // process the file // no file, invalid file, reject change - if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _umbracoSettingsSection) == false) + if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _contentSettings) == false) return null; // get the filepath diff --git a/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs b/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs index 7168ce194a..b833a60c2d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs @@ -16,12 +16,12 @@ namespace Umbraco.Web.PropertyEditors internal class UploadFileTypeValidator : IValueValidator { private readonly ILocalizedTextService _localizedTextService; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; + private readonly IContentSettings _contentSettings; - public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IUmbracoSettingsSection umbracoSettingsSection) + public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IContentSettings contentSettings) { _localizedTextService = localizedTextService; - _umbracoSettingsSection = umbracoSettingsSection; + _contentSettings = contentSettings; } public IEnumerable Validate(object value, string valueType, object dataTypeConfiguration) @@ -46,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors foreach (string filename in fileNames) { - if (IsValidFileExtension(filename, _umbracoSettingsSection) == false) + if (IsValidFileExtension(filename, _contentSettings) == false) { //we only store a single value for this editor so the 'member' or 'field' // we'll associate this error with will simply be called 'value' @@ -55,11 +55,11 @@ namespace Umbraco.Web.PropertyEditors } } - internal static bool IsValidFileExtension(string fileName, IUmbracoSettingsSection umbracoSettingsSection) + internal static bool IsValidFileExtension(string fileName, IContentSettings contentSettings) { if (fileName.IndexOf('.') <= 0) return false; var extension = new FileInfo(fileName).Extension.TrimStart("."); - return umbracoSettingsSection.Content.IsFileAllowedForUpload(extension); + return contentSettings.IsFileAllowedForUpload(extension); } } } diff --git a/src/Umbraco.Infrastructure/Routing/ContentFinderByConfigured404.cs b/src/Umbraco.Infrastructure/Routing/ContentFinderByConfigured404.cs index f8e21982e0..ac8d0980c4 100644 --- a/src/Umbraco.Infrastructure/Routing/ContentFinderByConfigured404.cs +++ b/src/Umbraco.Infrastructure/Routing/ContentFinderByConfigured404.cs @@ -16,14 +16,14 @@ namespace Umbraco.Web.Routing { private readonly ILogger _logger; private readonly IEntityService _entityService; - private readonly IContentSection _contentConfigSection; + private readonly IContentSettings _contentConfigSettings; private readonly IExamineManager _examineManager; - public ContentFinderByConfigured404(ILogger logger, IEntityService entityService, IContentSection contentConfigSection, IExamineManager examineManager) + public ContentFinderByConfigured404(ILogger logger, IEntityService entityService, IContentSettings contentConfigSettings, IExamineManager examineManager) { _logger = logger; _entityService = entityService; - _contentConfigSection = contentConfigSection; + _contentConfigSettings = contentConfigSettings; _examineManager = examineManager; } @@ -63,7 +63,7 @@ namespace Umbraco.Web.Routing } var error404 = NotFoundHandlerHelper.GetCurrentNotFoundPageId( - _contentConfigSection.Error404Collection.ToArray(), + _contentConfigSettings.Error404Collection.ToArray(), _entityService, new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor, _examineManager), errorCulture); diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs index 8cd9ed8c4f..7bb5c77e80 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs @@ -44,7 +44,6 @@ namespace Umbraco.Core.Runtime // composers composition - .ComposeConfiguration() .ComposeRepositories() .ComposeServices() .ComposeCoreMappingProfiles() diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 8e4401495d..38731ce21c 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -57,7 +57,7 @@ namespace Umbraco.Core.Runtime // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance' // as the second one captures the current value (null) and therefore fails _state = new RuntimeState(Logger, - Configs.Settings(), Configs.Global(), + Configs.Global(), new Lazy(() => mainDom), new Lazy(() => _factory.GetInstance()), UmbracoVersion,HostingEnvironment, BackOfficeInfo) @@ -171,7 +171,7 @@ namespace Umbraco.Core.Runtime // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance' // as the second one captures the current value (null) and therefore fails _state = new RuntimeState(Logger, - Configs.Settings(), Configs.Global(), + Configs.Global(), new Lazy(() => _factory.GetInstance()), new Lazy(() => _factory.GetInstance()), UmbracoVersion, HostingEnvironment, BackOfficeInfo) diff --git a/src/Umbraco.Infrastructure/RuntimeState.cs b/src/Umbraco.Infrastructure/RuntimeState.cs index 5952e73e62..eadb9fed21 100644 --- a/src/Umbraco.Infrastructure/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/RuntimeState.cs @@ -20,7 +20,6 @@ namespace Umbraco.Core public class RuntimeState : IRuntimeState { private readonly ILogger _logger; - private readonly IUmbracoSettingsSection _settings; private readonly IGlobalSettings _globalSettings; private readonly ConcurrentHashSet _applicationUrls = new ConcurrentHashSet(); private readonly Lazy _mainDom; @@ -32,13 +31,12 @@ namespace Umbraco.Core /// /// Initializes a new instance of the class. /// - public RuntimeState(ILogger logger, IUmbracoSettingsSection settings, IGlobalSettings globalSettings, + public RuntimeState(ILogger logger, IGlobalSettings globalSettings, Lazy mainDom, Lazy serverRegistrar, IUmbracoVersion umbracoVersion, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo) { _logger = logger; - _settings = settings; _globalSettings = globalSettings; _mainDom = mainDom; _serverRegistrar = serverRegistrar; diff --git a/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs b/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs index c8b8e617c9..d6c30b24c6 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs @@ -28,16 +28,16 @@ namespace Umbraco.Core.Services.Implement private readonly ILocalizationService _localizationService; private readonly INotificationsRepository _notificationsRepository; private readonly IGlobalSettings _globalSettings; - private readonly IContentSection _contentSection; + private readonly IContentSettings _contentSettings; private readonly ILogger _logger; private readonly IIOHelper _ioHelper; public NotificationService(IScopeProvider provider, IUserService userService, IContentService contentService, ILocalizationService localizationService, - ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IGlobalSettings globalSettings, IContentSection contentSection) + ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IGlobalSettings globalSettings, IContentSettings contentSettings) { _notificationsRepository = notificationsRepository; _globalSettings = globalSettings; - _contentSection = contentSection; + _contentSettings = contentSettings; _uowProvider = provider ?? throw new ArgumentNullException(nameof(provider)); _userService = userService ?? throw new ArgumentNullException(nameof(userService)); _contentService = contentService ?? throw new ArgumentNullException(nameof(contentService)); @@ -302,7 +302,7 @@ namespace Umbraco.Core.Services.Implement if (content.ContentType.VariesByNothing()) { - if (!_contentSection.DisableHtmlEmail) + if (!_contentSettings.DisableHtmlEmail) { //create the HTML summary for invariant content @@ -344,7 +344,7 @@ namespace Umbraco.Core.Services.Implement { //it's variant, so detect what cultures have changed - if (!_contentSection.DisableHtmlEmail) + if (!_contentSettings.DisableHtmlEmail) { //Create the HTML based summary (ul of culture names) @@ -406,13 +406,13 @@ namespace Umbraco.Core.Services.Implement summary.ToString()); // create the mail message - var mail = new MailMessage(_contentSection.NotificationEmailAddress, mailingUser.Email); + var mail = new MailMessage(_contentSettings.NotificationEmailAddress, mailingUser.Email); // populate the message mail.Subject = createSubject((mailingUser, subjectVars)); - if (_contentSection.DisableHtmlEmail) + if (_contentSettings.DisableHtmlEmail) { mail.IsBodyHtml = false; mail.Body = createBody((user: mailingUser, body: bodyVars, false)); diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs index b096235708..71ed653449 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs @@ -57,7 +57,6 @@ namespace Umbraco.Tests.Cache.PublishedCache _httpContextFactory = new FakeHttpContextFactory("~/Home"); - var umbracoSettings = Factory.GetInstance(); var globalSettings = Factory.GetInstance(); var umbracoContextAccessor = Factory.GetInstance(); diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementDefaultTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementDefaultTests.cs index 5fb896abb2..b14319b1b7 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementDefaultTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementDefaultTests.cs @@ -14,27 +14,27 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings [Test] public override void DisableHtmlEmail() { - Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail == false); + Assert.IsTrue(ContentSettings.DisableHtmlEmail == false); } [Test] public override void Can_Set_Multiple() { - Assert.IsTrue(SettingsSection.Content.Error404Collection.Count() == 1); - Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).Culture == null); - Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId == 1); + Assert.IsTrue(ContentSettings.Error404Collection.Count() == 1); + Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).Culture == null); + Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).ContentId == 1); } [Test] public override void ImageAutoFillProperties() { - Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.Count() == 1); - Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile"); - Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth"); - Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight"); - Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes"); - Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension"); + Assert.IsTrue(ContentSettings.ImageAutoFillProperties.Count() == 1); + Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile"); + Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth"); + Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight"); + Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes"); + Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension"); } - + } } diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs index 0245159c6e..9657091859 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs @@ -16,80 +16,80 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings [Test] public void EmailAddress() { - Assert.AreEqual(SettingsSection.Content.NotificationEmailAddress, "robot@umbraco.dk"); + Assert.AreEqual(ContentSettings.NotificationEmailAddress, "robot@umbraco.dk"); } [Test] public virtual void DisableHtmlEmail() { - Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail); + Assert.IsTrue(ContentSettings.DisableHtmlEmail); } [Test] public virtual void Can_Set_Multiple() { - Assert.AreEqual(SettingsSection.Content.Error404Collection.Count(), 3); - Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).Culture, "default"); - Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId, 1047); - Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentId); - Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentKey); - Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).Culture, "en-US"); - Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']"); - Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentId); - Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentKey); - Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).Culture, "en-UK"); - Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC")); - Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentKey); - Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentId); + Assert.AreEqual(ContentSettings.Error404Collection.Count(), 3); + Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(0).Culture, "default"); + Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(0).ContentId, 1047); + Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).HasContentId); + Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(0).HasContentKey); + Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(1).Culture, "en-US"); + Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']"); + Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(1).HasContentId); + Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(1).HasContentKey); + Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(2).Culture, "en-UK"); + Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC")); + Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(2).HasContentKey); + Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(2).HasContentId); } [Test] public void ImageFileTypes() { - Assert.IsTrue(SettingsSection.Content.ImageFileTypes.All(x => "jpeg,jpg,gif,bmp,png,tiff,tif".Split(',').Contains(x))); + Assert.IsTrue(ContentSettings.ImageFileTypes.All(x => "jpeg,jpg,gif,bmp,png,tiff,tif".Split(',').Contains(x))); } - + [Test] public virtual void ImageAutoFillProperties() { - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.Count(), 2); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2"); - Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.Count(), 2); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2"); + Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2"); } - + [Test] public void PreviewBadge() { - Assert.AreEqual(SettingsSection.Content.PreviewBadge, @"
Preview modeClick to end
"); + Assert.AreEqual(ContentSettings.PreviewBadge, @"
Preview modeClick to end
"); } [Test] public void ResolveUrlsFromTextString() { - Assert.IsFalse(SettingsSection.Content.ResolveUrlsFromTextString); + Assert.IsFalse(ContentSettings.ResolveUrlsFromTextString); } [Test] public void MacroErrors() { - Assert.AreEqual(SettingsSection.Content.MacroErrorBehaviour, MacroErrorBehaviour.Inline); + Assert.AreEqual(ContentSettings.MacroErrorBehaviour, MacroErrorBehaviour.Inline); } [Test] public void DisallowedUploadFiles() { - Assert.IsTrue(SettingsSection.Content.DisallowedUploadFiles.All(x => "ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd".Split(',').Contains(x))); + Assert.IsTrue(ContentSettings.DisallowedUploadFiles.All(x => "ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd".Split(',').Contains(x))); } [Test] public void AllowedUploadFiles() { - Assert.IsTrue(SettingsSection.Content.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x))); + Assert.IsTrue(ContentSettings.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x))); } [Test] @@ -107,16 +107,16 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings TestingDefaults = false; Debug.WriteLine("Extension being tested", extension); - Debug.WriteLine("AllowedUploadFiles: {0}", SettingsSection.Content.AllowedUploadFiles); - Debug.WriteLine("DisallowedUploadFiles: {0}", SettingsSection.Content.DisallowedUploadFiles); + Debug.WriteLine("AllowedUploadFiles: {0}", ContentSettings.AllowedUploadFiles); + Debug.WriteLine("DisallowedUploadFiles: {0}", ContentSettings.DisallowedUploadFiles); - var allowedContainsExtension = SettingsSection.Content.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)); - var disallowedContainsExtension = SettingsSection.Content.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)); + var allowedContainsExtension = ContentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)); + var disallowedContainsExtension = ContentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)); Debug.WriteLine("AllowedContainsExtension: {0}", allowedContainsExtension); Debug.WriteLine("DisallowedContainsExtension: {0}", disallowedContainsExtension); - Assert.AreEqual(SettingsSection.Content.IsFileAllowedForUpload(extension), expected); + Assert.AreEqual(ContentSettings.IsFileAllowedForUpload(extension), expected); } } } diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/UmbracoSettingsTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/UmbracoSettingsTests.cs index 364c30eecc..7a82f3c070 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/UmbracoSettingsTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/UmbracoSettingsTests.cs @@ -32,8 +32,6 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings Assert.IsNotNull(Settings); } - - protected IUmbracoSettingsSection SettingsSection => Settings; private UmbracoSettingsSection Settings { get; set; } protected ILoggingSettings LoggingSettings => Settings.Logging; @@ -42,5 +40,6 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings protected ISecuritySettings SecuritySettings => Settings.Security; protected IUserPasswordConfiguration UserPasswordConfiguration => Settings.Security.UserPasswordConfiguration; protected IMemberPasswordConfiguration MemberPasswordConfiguration => Settings.Security.MemberPasswordConfiguration; + protected IContentSettings ContentSettings => Settings.Content; } } diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs index 8b8b71304a..bf726c6fd8 100644 --- a/src/Umbraco.Tests/IO/FileSystemsTests.cs +++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs @@ -34,18 +34,18 @@ namespace Umbraco.Tests.IO composition.Register(_ => Mock.Of()); composition.Register(_ => Mock.Of()); - composition.Register(_ => Mock.Of()); + composition.Register(_ => Mock.Of()); composition.Register(_ => TestHelper.ShortStringHelper); composition.Register(_ => TestHelper.IOHelper); composition.RegisterUnique(); composition.RegisterUnique(TestHelper.IOHelper); composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); - composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); composition.ComposeFileSystems(); - composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); _factory = composition.CreateFactory(); diff --git a/src/Umbraco.Tests/Models/ContentExtensionsTests.cs b/src/Umbraco.Tests/Models/ContentExtensionsTests.cs index 87bd661015..bab3a540be 100644 --- a/src/Umbraco.Tests/Models/ContentExtensionsTests.cs +++ b/src/Umbraco.Tests/Models/ContentExtensionsTests.cs @@ -29,7 +29,7 @@ namespace Umbraco.Tests.Models Composition.ComposeFileSystems(); Composition.Register(_ => Mock.Of()); - Composition.Register(_ => Mock.Of()); + Composition.Register(_ => Mock.Of()); // all this is required so we can validate properties... var editor = new TextboxPropertyEditor(Mock.Of(), Mock.Of(), Mock.Of(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" }; diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs index 7dec69e3be..d5117c6a69 100644 --- a/src/Umbraco.Tests/Models/ContentTests.cs +++ b/src/Umbraco.Tests/Models/ContentTests.cs @@ -39,7 +39,7 @@ namespace Umbraco.Tests.Models Composition.ComposeFileSystems(); Composition.Register(_ => Mock.Of()); - Composition.Register(_ => Mock.Of()); + Composition.Register(_ => Mock.Of()); // all this is required so we can validate properties... var editor = new TextboxPropertyEditor(Mock.Of(), Mock.Of(), Mock.Of(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" }; diff --git a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs index 5c6d5c6947..cc923df4b4 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs @@ -34,7 +34,7 @@ namespace Umbraco.Tests.Models.Mapping Composition.ComposeFileSystems(); Composition.Register(_ => Mock.Of()); - Composition.Register(_ => Mock.Of()); + Composition.Register(_ => Mock.Of()); // all this is required so we can validate properties... var editor = new TextboxPropertyEditor(Mock.Of(), Mock.Of(), Mock.Of(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" }; diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs index 2b9c4a32e2..632f433c5b 100644 --- a/src/Umbraco.Tests/Models/MediaXmlTest.cs +++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs @@ -31,13 +31,10 @@ namespace Umbraco.Tests.Models // and then, this will reset the width, height... because the file does not exist, of course ;-( var logger = Mock.Of(); var scheme = Mock.Of(); - var config = Mock.Of(); - var dataTypeService = Mock.Of(); - var localizationService = Mock.Of(); - var umbracoSettingsSection = TestObjects.GetUmbracoSettings(); + var config = Mock.Of(); var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, logger, ShortStringHelper); - var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, umbracoSettingsSection); + var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper); var media = MockedMedia.CreateMediaImage(mediaType, -1); media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests diff --git a/src/Umbraco.Tests/Models/VariationTests.cs b/src/Umbraco.Tests/Models/VariationTests.cs index d322926783..f353ee3c8a 100644 --- a/src/Umbraco.Tests/Models/VariationTests.cs +++ b/src/Umbraco.Tests/Models/VariationTests.cs @@ -35,7 +35,7 @@ namespace Umbraco.Tests.Models var configs = TestHelper.GetConfigs(); configs.Add(SettingsForTests.GetDefaultGlobalSettings); - configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + configs.Add(SettingsForTests.GenerateMockContentSettings); _factory = Mock.Of(); diff --git a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs b/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs index 281e5a9365..919386f491 100644 --- a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs +++ b/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs @@ -85,10 +85,8 @@ namespace Umbraco.Tests.PropertyEditors var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, logger, shortStringHelper); - var umbracoSettingsSection = Mock.Of(); - var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new ImageCropperPropertyEditor(Mock.Of(), mediaFileSystem, Mock.Of(), Mock.Of(), Mock.Of(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of(), umbracoSettingsSection)) { Id = 1 }); + new DataType(new ImageCropperPropertyEditor(Mock.Of(), mediaFileSystem, Mock.Of(), Mock.Of(), Mock.Of(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of())) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs index de12fcf7aa..c1f571aa91 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs @@ -63,7 +63,7 @@ namespace Umbraco.Tests.PublishedContent Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs); var globalSettings = new GlobalSettings(TestHelper.IOHelper); var hostingEnvironment = Mock.Of(); - configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + configs.Add(SettingsForTests.GenerateMockContentSettings); configs.Add(() => globalSettings); Mock.Get(factory).Setup(x => x.GetInstance(typeof(IPublishedModelFactory))).Returns(PublishedModelFactory); diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs index 08da25ba9a..c5c2f678ee 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs @@ -55,7 +55,7 @@ namespace Umbraco.Tests.PublishedContent var configs = TestHelper.GetConfigs(); Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs); var globalSettings = new GlobalSettings(TestHelper.IOHelper); - configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + configs.Add(SettingsForTests.GenerateMockContentSettings); configs.Add(() => globalSettings); var publishedModelFactory = new NoopPublishedModelFactory(); diff --git a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs index a8d45984f1..b9a5432b7c 100644 --- a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs +++ b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs @@ -34,14 +34,12 @@ namespace Umbraco.Tests.Routing var logger = Mock.Of(); var mediaFileSystemMock = Mock.Of(); - var contentSection = Mock.Of(); + var contentSection = Mock.Of(); var dataTypeService = Mock.Of(); - var umbracoSettingsSection = TestObjects.GetUmbracoSettings(); - var propertyEditors = new MediaUrlGeneratorCollection(new IMediaUrlGenerator[] { - new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, umbracoSettingsSection), - new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, umbracoSettingsSection), + new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), + new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService), }); _mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors, UriUtility); } diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs index de7e6d52b6..e4ee8a3580 100644 --- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs +++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs @@ -32,7 +32,7 @@ namespace Umbraco.Tests.Routing //create the module var logger = Mock.Of(); var globalSettings = TestObjects.GetGlobalSettings(); - var runtime = new RuntimeState(logger, Mock.Of(), globalSettings, + var runtime = new RuntimeState(logger, globalSettings, new Lazy(), new Lazy(), UmbracoVersion, HostingEnvironment, BackOfficeInfo); _module = new UmbracoInjectedModule diff --git a/src/Umbraco.Tests/Routing/UrlProviderTests.cs b/src/Umbraco.Tests/Routing/UrlProviderTests.cs index b57c881404..d38fa3ea3e 100644 --- a/src/Umbraco.Tests/Routing/UrlProviderTests.cs +++ b/src/Umbraco.Tests/Routing/UrlProviderTests.cs @@ -34,7 +34,7 @@ namespace Umbraco.Tests.Routing protected override void ComposeSettings() { - Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings); } diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index 0d26e516ff..f10e966cf7 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -98,7 +98,7 @@ namespace Umbraco.Tests.Runtimes { var configs = new ConfigsFactory().Create(_ioHelper); configs.Add(SettingsForTests.GetDefaultGlobalSettings); - configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + configs.Add(SettingsForTests.GenerateMockContentSettings); configs.Add(SettingsForTests.GetDefaultHostingSettings); return configs; } @@ -208,7 +208,7 @@ namespace Umbraco.Tests.Runtimes public void Compose(Composition composition) { - composition.Register(factory => SettingsForTests.GetDefaultUmbracoSettings()); + composition.Register(factory => SettingsForTests.GenerateMockContentSettings()); composition.RegisterUnique(); composition.Components().Append(); diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index 6811f9f8de..225506093e 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -70,7 +70,7 @@ namespace Umbraco.Tests.Runtimes var mainDom = new SimpleMainDom(); var umbracoVersion = TestHelper.GetUmbracoVersion(); var backOfficeInfo = TestHelper.GetBackOfficeInfo(); - var runtimeState = new RuntimeState(logger, null, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance()), umbracoVersion, hostingEnvironment, backOfficeInfo); + var runtimeState = new RuntimeState(logger, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance()), umbracoVersion, hostingEnvironment, backOfficeInfo); var configs = TestHelper.GetConfigs(); var variationContextAccessor = TestHelper.VariationContextAccessor; @@ -121,7 +121,7 @@ namespace Umbraco.Tests.Runtimes // configure composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); - composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); // create and register the factory Current.Factory = factory = composition.CreateFactory(); diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs index 7b60a9fae2..fd37192da2 100644 --- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs @@ -42,7 +42,7 @@ namespace Umbraco.Tests.Scoping composition.WithCollectionBuilder(); composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); - composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); Current.Reset(); Current.Factory = composition.CreateFactory(); diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs index 783beafb2e..7a388417bc 100644 --- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs @@ -112,7 +112,7 @@ namespace Umbraco.Tests.Scoping settings); } - protected IUmbracoContext GetUmbracoContextNu(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable urlProviders = null) + protected IUmbracoContext GetUmbracoContextNu(string url, RouteData routeData = null, bool setSingleton = false) { // ensure we have a PublishedSnapshotService var service = PublishedSnapshotService as PublishedSnapshotService; diff --git a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs index 3e62b52689..852872fca0 100644 --- a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs @@ -44,7 +44,7 @@ namespace Umbraco.Tests.Scoping protected override void ComposeSettings() { - Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings); } diff --git a/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs b/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs index e3c9657b34..7ab86723d7 100644 --- a/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs +++ b/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs @@ -40,20 +40,15 @@ namespace Umbraco.Tests.TestHelpers /// Returns generated settings which can be stubbed to return whatever values necessary ///
/// - public static IUmbracoSettingsSection GenerateMockUmbracoSettings() + public static IContentSettings GenerateMockContentSettings() { - var settings = new Mock(); - var content = new Mock(); - - settings.Setup(x => x.Content).Returns(content.Object); + var content = new Mock(); //Now configure some defaults - the defaults in the config section classes do NOT pertain to the mocked data!! - settings.Setup(x => x.Content.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties()); - settings.Setup(x => x.Content.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes()); - - - return settings.Object; + content.Setup(x => x.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties()); + content.Setup(x => x.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes()); + return content.Object; } //// from appSettings @@ -105,7 +100,6 @@ namespace Umbraco.Tests.TestHelpers _defaultGlobalSettings = null; } - private static IUmbracoSettingsSection _defaultUmbracoSettings; private static IGlobalSettings _defaultGlobalSettings; private static IHostingSettings _defaultHostingSettings; @@ -137,22 +131,6 @@ namespace Umbraco.Tests.TestHelpers return config; } - internal static IUmbracoSettingsSection GetDefaultUmbracoSettings() - { - if (_defaultUmbracoSettings == null) - { - // TODO: Just make this mocks instead of reading from the config - - var config = new FileInfo(TestHelper.MapPathForTest("~/Configurations/UmbracoSettings/web.config")); - - var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = config.FullName }; - var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); - _defaultUmbracoSettings = configuration.GetSection("umbracoConfiguration/defaultSettings") as UmbracoSettingsSection; - } - - return _defaultUmbracoSettings; - } - public static IWebRoutingSettings GenerateMockWebRoutingSettings() { var mock = new Mock(); diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs index 53eee0fbb2..0bae38f26d 100644 --- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs +++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs @@ -56,7 +56,6 @@ namespace Umbraco.Tests.TestHelpers { return new RuntimeState( Mock.Of(), - Mock.Of(), Mock.Of(), new Lazy(), new Lazy(), diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs index c1bc2f913b..93ae4a13b1 100644 --- a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs +++ b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs @@ -140,17 +140,6 @@ namespace Umbraco.Tests.TestHelpers return umbracoContextFactory.EnsureUmbracoContext().UmbracoContext; } - public IUmbracoSettingsSection GetUmbracoSettings() - { - // FIXME: Why not use the SettingsForTest.GenerateMock ... ? - // FIXME: Shouldn't we use the default ones so they are the same instance for each test? - - var umbracoSettingsMock = new Mock(); - var webRoutingSectionMock = new Mock(); - webRoutingSectionMock.Setup(x => x.UrlProviderMode).Returns(UrlMode.Auto.ToString()); - return umbracoSettingsMock.Object; - } - public IGlobalSettings GetGlobalSettings() { return SettingsForTests.GetDefaultGlobalSettings(); diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects.cs b/src/Umbraco.Tests/TestHelpers/TestObjects.cs index f237fb0fc7..2af409e024 100644 --- a/src/Umbraco.Tests/TestHelpers/TestObjects.cs +++ b/src/Umbraco.Tests/TestHelpers/TestObjects.cs @@ -95,7 +95,7 @@ namespace Umbraco.Tests.TestHelpers ILogger logger, IIOHelper ioHelper, IGlobalSettings globalSettings, - IUmbracoSettingsSection umbracoSettings, + IContentSettings contentSettings, IEventMessagesFactory eventMessagesFactory, UrlSegmentProviderCollection urlSegmentProviders, TypeLoader typeLoader, @@ -161,7 +161,7 @@ namespace Umbraco.Tests.TestHelpers var dataTypeService = GetLazyService(factory, c => new DataTypeService(scopeProvider, logger, eventMessagesFactory, GetRepo(c), GetRepo(c), GetRepo(c), GetRepo(c), GetRepo(c), ioHelper, localizedTextService.Value, localizationService.Value, TestHelper.ShortStringHelper)); var propertyValidationService = new Lazy(() => new PropertyValidationService(propertyEditorCollection, dataTypeService.Value)); var contentService = GetLazyService(factory, c => new ContentService(scopeProvider, logger, eventMessagesFactory, GetRepo(c), GetRepo(c), GetRepo(c), GetRepo(c), GetRepo(c), GetRepo(c), propertyValidationService)); - var notificationService = GetLazyService(factory, c => new NotificationService(scopeProvider, userService.Value, contentService.Value, localizationService.Value, logger, ioHelper, GetRepo(c), globalSettings, umbracoSettings.Content)); + var notificationService = GetLazyService(factory, c => new NotificationService(scopeProvider, userService.Value, contentService.Value, localizationService.Value, logger, ioHelper, GetRepo(c), globalSettings, contentSettings)); var serverRegistrationService = GetLazyService(factory, c => new ServerRegistrationService(scopeProvider, logger, eventMessagesFactory, GetRepo(c), TestHelper.GetHostingEnvironment())); var memberGroupService = GetLazyService(factory, c => new MemberGroupService(scopeProvider, logger, eventMessagesFactory, GetRepo(c))); var memberService = GetLazyService(factory, c => new MemberService(scopeProvider, logger, eventMessagesFactory, memberGroupService.Value, GetRepo(c), GetRepo(c), GetRepo(c), GetRepo(c))); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 10449ac785..41c05276fb 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -411,7 +411,6 @@ namespace Umbraco.Tests.Testing protected virtual void ComposeSettings() { - Composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); Composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); Composition.Configs.Add(SettingsForTests.GetDefaultHostingSettings); Composition.Configs.Add(SettingsForTests.GenerateMockRequestHandlerSettings); @@ -419,6 +418,7 @@ namespace Umbraco.Tests.Testing Composition.Configs.Add(SettingsForTests.GenerateMockSecuritySettings); Composition.Configs.Add(SettingsForTests.GenerateMockUserPasswordConfiguration); Composition.Configs.Add(SettingsForTests.GenerateMockMemberPasswordConfiguration); + Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings); //Composition.Configs.Add(() => new DefaultUserPasswordConfig()); } @@ -432,10 +432,6 @@ namespace Umbraco.Tests.Testing // default Datalayer/Repositories/SQL/Database/etc... Composition.ComposeRepositories(); - // register basic stuff that might need to be there for some container resolvers to work - Composition.RegisterUnique(factory => factory.GetInstance().Content); - Composition.RegisterUnique(factory => factory.GetInstance()); - Composition.RegisterUnique(); Composition.RegisterUnique(); diff --git a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs index e23a4db1dc..14bbc5f1fb 100644 --- a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs +++ b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs @@ -89,7 +89,7 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), ShortStringHelper, Factory.GetInstance(), - Factory.GetInstance(), + Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), @@ -162,7 +162,7 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), ShortStringHelper, Factory.GetInstance(), - Factory.GetInstance(), + Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), @@ -205,7 +205,7 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), ShortStringHelper, Factory.GetInstance(), - Factory.GetInstance(), + Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), @@ -283,7 +283,7 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), ShortStringHelper, Factory.GetInstance(), - Factory.GetInstance(), + Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs index 81b1ea60aa..ab916b8428 100644 --- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs @@ -385,11 +385,7 @@ namespace Umbraco.Tests.Web.Mvc ViewContext GetViewContext() { - var settings = SettingsForTests.GetDefaultUmbracoSettings(); - var logger = Mock.Of(); - var umbracoContext = GetUmbracoContext( - logger, settings, - "/dang", 0); + var umbracoContext = GetUmbracoContext("/dang", 0); var publishedRouter = BaseWebTest.CreatePublishedRouter(SettingsForTests.GenerateMockWebRoutingSettings()); var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/dang")); @@ -404,7 +400,7 @@ namespace Umbraco.Tests.Web.Mvc return context; } - protected IUmbracoContext GetUmbracoContext(ILogger logger, IUmbracoSettingsSection umbracoSettings, string url, int templateId, RouteData routeData = null, bool setSingleton = false) + protected IUmbracoContext GetUmbracoContext(string url, int templateId, RouteData routeData = null, bool setSingleton = false) { var svcCtx = GetServiceContext(); diff --git a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml index 35654e7a41..986fa2dc76 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml @@ -48,7 +48,7 @@ redirectUrl = Url.Action("AuthorizeUpgrade", "BackOffice") }); } - @Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings) + @Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.ContentSettings, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings)