From 899d325ca16763f4e3184a49258a895e616a4e77 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 10 Dec 2014 11:42:45 +0100 Subject: [PATCH] Updates unit tests to use the newer new ContentType method and obsoletes the old one --- src/Umbraco.Core/Models/ContentType.cs | 17 +++++++++-------- .../PublishedContentExtensionTests.cs | 2 +- .../Services/ContentTypeServiceTests.cs | 6 +++--- .../TestHelpers/Entities/MockedContentTypes.cs | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index f8f19ef8d1..fc53a21c3f 100644 --- a/src/Umbraco.Core/Models/ContentType.cs +++ b/src/Umbraco.Core/Models/ContentType.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.Models { private int _defaultTemplate; private IEnumerable _allowedTemplates; - + /// /// Constuctor for creating a ContentType with the parent's id. /// @@ -31,9 +31,10 @@ namespace Umbraco.Core.Models /// /// Use this to ensure inheritance from parent. /// - public ContentType(IContentType parent) : this(parent, null) - { - } + [Obsolete("This method is obsolete, use ContentType(IContentType parent, string alias) instead.", false)] + public ContentType(IContentType parent) : this(parent, null) + { + } /// /// Constuctor for creating a ContentType with the parent as an inherited type. @@ -49,7 +50,7 @@ namespace Umbraco.Core.Models private static readonly PropertyInfo DefaultTemplateSelector = ExpressionHelper.GetPropertyInfo(x => x.DefaultTemplateId); private static readonly PropertyInfo AllowedTemplatesSelector = ExpressionHelper.GetPropertyInfo>(x => x.AllowedTemplates); - + /// /// Gets or sets the alias of the default Template. /// @@ -106,7 +107,7 @@ namespace Umbraco.Core.Models } DefaultTemplateId = template.Id; - if(_allowedTemplates.Any(x => x != null && x.Id == template.Id) == false) + if (_allowedTemplates.Any(x => x != null && x.Id == template.Id) == false) { var templates = AllowedTemplates.ToList(); templates.Add(template); @@ -140,7 +141,7 @@ namespace Umbraco.Core.Models { base.AddingEntity(); - if(Key == Guid.Empty) + if (Key == Guid.Empty) Key = Guid.NewGuid(); } @@ -151,7 +152,7 @@ namespace Umbraco.Core.Models /// [Obsolete("Use DeepCloneWithResetIdentities instead")] public IContentType Clone(string alias) - { + { return DeepCloneWithResetIdentities(alias); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs index 5a9067a095..b5f1b255c6 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs @@ -74,7 +74,7 @@ namespace Umbraco.Tests.PublishedContent { var contentTypeService = ctx.Application.Services.ContentTypeService; var baseType = new ContentType(-1) {Alias = "base", Name = "Base"}; - var inheritedType = new ContentType(baseType) {Alias = "inherited", Name = "Inherited"}; + var inheritedType = new ContentType(baseType, baseType.Alias) {Alias = "inherited", Name = "Inherited"}; contentTypeService.Save(baseType); contentTypeService.Save(inheritedType); createContentTypes = false; diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs index 5898c27853..7799d46474 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs @@ -178,7 +178,7 @@ namespace Umbraco.Tests.Services /*,"Navigation"*/); cts.Save(ctBase); - var ctHomePage = new ContentType(ctBase) + var ctHomePage = new ContentType(ctBase, ctBase.Alias) { Name = "Home Page", Alias = "HomePage", @@ -487,7 +487,7 @@ namespace Umbraco.Tests.Services private ContentType CreateBannerComponent(ContentType parent) { - var banner = new ContentType(parent) + var banner = new ContentType(parent, parent.Alias) { Alias = "banner", Name = "Banner Component", @@ -535,7 +535,7 @@ namespace Umbraco.Tests.Services private ContentType CreateHomepage(ContentType parent) { - var contentType = new ContentType(parent) + var contentType = new ContentType(parent, parent.Alias) { Alias = "homepage", Name = "Homepage", diff --git a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs index 812495d3da..4227a8303b 100644 --- a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs +++ b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs @@ -94,7 +94,7 @@ namespace Umbraco.Tests.TestHelpers.Entities public static ContentType CreateSimpleContentType(string alias, string name, IContentType parent = null, bool randomizeAliases = false) { - var contentType = parent == null ? new ContentType(-1) : new ContentType(parent); + var contentType = parent == null ? new ContentType(-1) : new ContentType(parent, parent.Alias); contentType.Alias = alias; contentType.Name = name;