Ensures mocked test entities don't have dirty properties on initialization. Ensures content xml structure

is rebuilt when a content type's alias is changed or a property type is removed from it. Adds ability  to rebuild
content xml structures for specified content types, not for all content. Adds ContentTypeExtensions and
more unit tests for ContentTypeTests. Changes RuntimeCacheProvider to use new ConcurrentHashSet instead of a dictionary
with the same key/value. Adds overload to IRepositoryCacheProvider to clear cache by type. Clears the IContent cache when
a Content type is saved.
All relates to fixing #U4-1943
This commit is contained in:
Shannon Deminick
2013-03-20 20:53:12 +06:00
parent 6c40f32c2a
commit adedc9b64b
16 changed files with 587 additions and 53 deletions

View File

@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Models
{
public static class ContentTypeExtensions
{
/// <summary>
/// Get all descendant content types
/// </summary>
/// <param name="contentType"></param>
/// <returns></returns>
public static IEnumerable<IContentType> Descendants(this IContentType contentType)
{
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var descendants = contentTypeService.GetContentTypeChildren(contentType.Id)
.FlattenList(type => contentTypeService.GetContentTypeChildren(type.Id));
return descendants;
}
/// <summary>
/// Get all descendant and self content types
/// </summary>
/// <param name="contentType"></param>
/// <returns></returns>
public static IEnumerable<IContentType> DescendantsAndSelf(this IContentType contentType)
{
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var descendants = contentTypeService.GetContentTypeChildren(contentType.Id)
.FlattenList(type => contentTypeService.GetContentTypeChildren(type.Id));
var descendantsAndSelf = new[] { contentType }.Concat(contentType.Descendants());
return descendantsAndSelf;
}
}
}