Merge remote-tracking branch 'Umbraco/netcore/dev' into netcore/feature/users

This commit is contained in:
Scott Brady
2020-04-30 09:13:20 +01:00
47 changed files with 2228 additions and 836 deletions
+3
View File
@@ -21,6 +21,9 @@
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Umbraco.Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Umbraco.Tests.UnitTests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Umbraco.Tests.Benchmarks</_Parameter1>
</AssemblyAttribute>
@@ -0,0 +1,157 @@
using System;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class ContentBuilder
: BuilderBase<Content>,
IBuildContentTypes,
IWithIdBuilder,
IWithKeyBuilder,
IWithParentIdBuilder,
IWithCreatorIdBuilder,
IWithCreateDateBuilder,
IWithUpdateDateBuilder,
IWithNameBuilder,
IWithTrashedBuilder,
IWithLevelBuilder,
IWithPathBuilder,
IWithSortOrderBuilder
{
private ContentTypeBuilder _contentTypeBuilder;
private GenericDictionaryBuilder<ContentBuilder, string, object> _propertyDataBuilder;
private int? _id;
private Guid? _key;
private DateTime? _createDate;
private DateTime? _updateDate;
private int? _parentId;
private string _name;
private int? _creatorId;
private int? _level;
private string _path;
private int? _sortOrder;
private bool? _trashed;
public ContentTypeBuilder AddContentType()
{
var builder = new ContentTypeBuilder(this);
_contentTypeBuilder = builder;
return builder;
}
public override Content Build()
{
var id = _id ?? 1;
var key = _key ?? Guid.NewGuid();
var parentId = _parentId ?? -1;
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
var name = _name ?? Guid.NewGuid().ToString();
var creatorId = _creatorId ?? 1;
var level = _level ?? 1;
var path = _path ?? $"-1,{id}";
var sortOrder = _sortOrder ?? 0;
var trashed = _trashed ?? false;
if (_contentTypeBuilder == null)
{
throw new InvalidOperationException("A member cannot be constructed without providing a member type. Use AddContentType().");
}
var memberType = _contentTypeBuilder.Build();
var member = new Content(name, parentId, memberType)
{
Id = id,
Key = key,
CreateDate = createDate,
UpdateDate = updateDate,
CreatorId = creatorId,
Level = level,
Path = path,
SortOrder = sortOrder,
Trashed = trashed,
};
if (_propertyDataBuilder != null)
{
var propertyData = _propertyDataBuilder.Build();
foreach (var kvp in propertyData)
{
member.SetValue(kvp.Key, kvp.Value);
}
member.ResetDirtyProperties(false);
}
return member;
}
int? IWithIdBuilder.Id
{
get => _id;
set => _id = value;
}
Guid? IWithKeyBuilder.Key
{
get => _key;
set => _key = value;
}
int? IWithCreatorIdBuilder.CreatorId
{
get => _creatorId;
set => _creatorId = value;
}
DateTime? IWithCreateDateBuilder.CreateDate
{
get => _createDate;
set => _createDate = value;
}
DateTime? IWithUpdateDateBuilder.UpdateDate
{
get => _updateDate;
set => _updateDate = value;
}
string IWithNameBuilder.Name
{
get => _name;
set => _name = value;
}
bool? IWithTrashedBuilder.Trashed
{
get => _trashed;
set => _trashed = value;
}
int? IWithLevelBuilder.Level
{
get => _level;
set => _level = value;
}
string IWithPathBuilder.Path
{
get => _path;
set => _path = value;
}
int? IWithSortOrderBuilder.SortOrder
{
get => _sortOrder;
set => _sortOrder = value;
}
int? IWithParentIdBuilder.ParentId
{
get => _parentId;
set => _parentId = value;
}
}
}
@@ -0,0 +1,201 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Models;
using Umbraco.Core.Strings;
using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public abstract class ContentTypeBaseBuilder<TParent, TType>
: ChildBuilderBase<TParent, TType>,
IBuildPropertyGroups,
IWithIdBuilder,
IWithKeyBuilder,
IWithAliasBuilder,
IWithNameBuilder,
IWithParentIdBuilder,
IWithPathBuilder,
IWithLevelBuilder,
IWithSortOrderBuilder,
IWithCreatorIdBuilder,
IWithCreateDateBuilder,
IWithUpdateDateBuilder,
IWithDescriptionBuilder,
IWithIconBuilder,
IWithThumbnailBuilder,
IWithTrashedBuilder,
IWithIsContainerBuilder where TParent : IBuildContentTypes
{
private int? _id;
private Guid? _key;
private string _alias;
private string _name;
private int? _parentId;
private int? _level;
private string _path;
private int? _sortOrder;
private int? _creatorId;
private DateTime? _createDate;
private DateTime? _updateDate;
private string _description;
private string _icon;
private string _thumbnail;
private bool? _trashed;
private bool? _isContainer;
protected IShortStringHelper ShortStringHelper => new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
public ContentTypeBaseBuilder(TParent parentBuilder) : base(parentBuilder)
{
}
protected int GetId() => _id ?? 1;
protected Guid GetKey() => _key ?? Guid.NewGuid();
protected DateTime GetCreateDate() => _createDate ?? DateTime.Now;
protected DateTime GetUpdateDate() => _updateDate ?? DateTime.Now;
protected string GetName() => _name ?? Guid.NewGuid().ToString();
protected string GetAlias() => _alias ?? GetName().ToCamelCase();
protected int GetParentId() => _parentId ?? -1;
protected int GetLevel() => _level ?? 0;
protected string GetPath() => _path ?? _path ?? $"-1,{GetId()}";
protected int GetSortOrder() => _sortOrder ?? 0;
protected string GetDescription() => _description ?? string.Empty;
protected string GetIcon() => _icon ?? "icon-document";
protected string GetThumbnail() => _thumbnail ?? "folder.png";
protected int GetCreatorId() => _creatorId ?? 0;
protected bool GetTrashed() => _trashed ?? false;
protected bool GetIsContainer() => _isContainer ?? false;
protected void BuildPropertyGroups(ContentTypeCompositionBase contentType, IEnumerable<PropertyGroup> propertyGroups)
{
foreach (var propertyGroup in propertyGroups)
{
contentType.PropertyGroups.Add(propertyGroup);
}
}
protected void BuildPropertyTypeIds(ContentTypeCompositionBase contentType, int? propertyTypeIdsIncrementingFrom)
{
if (propertyTypeIdsIncrementingFrom.HasValue)
{
var i = propertyTypeIdsIncrementingFrom.Value;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
}
}
int? IWithIdBuilder.Id
{
get => _id;
set => _id = value;
}
Guid? IWithKeyBuilder.Key
{
get => _key;
set => _key = value;
}
string IWithAliasBuilder.Alias
{
get => _alias;
set => _alias = value;
}
string IWithNameBuilder.Name
{
get => _name;
set => _name = value;
}
int? IWithParentIdBuilder.ParentId
{
get => _parentId;
set => _parentId = value;
}
int? IWithLevelBuilder.Level
{
get => _level;
set => _level = value;
}
string IWithPathBuilder.Path
{
get => _path;
set => _path = value;
}
int? IWithSortOrderBuilder.SortOrder
{
get => _sortOrder;
set => _sortOrder = value;
}
int? IWithCreatorIdBuilder.CreatorId
{
get => _creatorId;
set => _creatorId = value;
}
DateTime? IWithCreateDateBuilder.CreateDate
{
get => _createDate;
set => _createDate = value;
}
DateTime? IWithUpdateDateBuilder.UpdateDate
{
get => _updateDate;
set => _updateDate = value;
}
string IWithDescriptionBuilder.Description
{
get => _description;
set => _description = value;
}
string IWithIconBuilder.Icon
{
get => _icon;
set => _icon = value;
}
string IWithThumbnailBuilder.Thumbnail
{
get => _thumbnail;
set => _thumbnail = value;
}
bool? IWithTrashedBuilder.Trashed
{
get => _trashed;
set => _trashed = value;
}
bool? IWithIsContainerBuilder.IsContainer
{
get => _isContainer;
set => _isContainer = value;
}
}
}
@@ -0,0 +1,98 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class ContentTypeBuilder
: ContentTypeBaseBuilder<ContentBuilder, IContentType>,
IWithPropertyTypeIdsIncrementingFrom
{
private List<PropertyGroupBuilder<ContentTypeBuilder>> _propertyGroupBuilders = new List<PropertyGroupBuilder<ContentTypeBuilder>>();
private List<TemplateBuilder> _templateBuilders = new List<TemplateBuilder>();
private List<ContentTypeSortBuilder> _allowedContentTypeBuilders = new List<ContentTypeSortBuilder>();
private int? _propertyTypeIdsIncrementingFrom;
private int? _defaultTemplateId;
public ContentTypeBuilder() : base(null)
{
}
public ContentTypeBuilder(ContentBuilder parentBuilder) : base(parentBuilder)
{
}
public ContentTypeBuilder WithDefaultTemplateId(int templateId)
{
_defaultTemplateId = templateId;
return this;
}
public PropertyGroupBuilder<ContentTypeBuilder> AddPropertyGroup()
{
var builder = new PropertyGroupBuilder<ContentTypeBuilder>(this);
_propertyGroupBuilders.Add(builder);
return builder;
}
public TemplateBuilder AddAllowedTemplate()
{
var builder = new TemplateBuilder(this);
_templateBuilders.Add(builder);
return builder;
}
public ContentTypeSortBuilder AddAllowedContentType()
{
var builder = new ContentTypeSortBuilder(this);
_allowedContentTypeBuilders.Add(builder);
return builder;
}
public override IContentType Build()
{
var contentType = new ContentType(ShortStringHelper, GetParentId())
{
Id = GetId(),
Key = GetKey(),
CreateDate = GetCreateDate(),
UpdateDate = GetUpdateDate(),
Alias = GetAlias(),
Name = GetName(),
Level = GetLevel(),
Path = GetPath(),
SortOrder = GetSortOrder(),
Description = GetDescription(),
Icon = GetIcon(),
Thumbnail = GetThumbnail(),
CreatorId = GetCreatorId(),
Trashed = GetTrashed(),
IsContainer = GetIsContainer(),
};
BuildPropertyGroups(contentType, _propertyGroupBuilders.Select(x => x.Build()));
BuildPropertyTypeIds(contentType, _propertyTypeIdsIncrementingFrom);
contentType.AllowedTemplates = _templateBuilders.Select(x => x.Build());
contentType.AllowedContentTypes = _allowedContentTypeBuilders.Select(x => x.Build());
if (_defaultTemplateId.HasValue)
{
contentType.SetDefaultTemplate(contentType.AllowedTemplates
.SingleOrDefault(x => x.Id == _defaultTemplateId.Value));
}
contentType.ResetDirtyProperties(false);
return contentType;
}
int? IWithPropertyTypeIdsIncrementingFrom.PropertyTypeIdsIncrementingFrom
{
get => _propertyTypeIdsIncrementingFrom;
set => _propertyTypeIdsIncrementingFrom = value;
}
}
}
@@ -0,0 +1,53 @@
using System;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class ContentTypeSortBuilder
: ChildBuilderBase<ContentTypeBuilder, ContentTypeSort>,
IWithIdBuilder,
IWithAliasBuilder,
IWithSortOrderBuilder
{
private int? _id;
private string _alias;
private int? _sortOrder;
public ContentTypeSortBuilder() : base(null)
{
}
public ContentTypeSortBuilder(ContentTypeBuilder parentBuilder) : base(parentBuilder)
{
}
public override ContentTypeSort Build()
{
var id = _id ?? 1;
var alias = _alias ?? Guid.NewGuid().ToString().ToCamelCase();
var sortOrder = _sortOrder ?? 0;
return new ContentTypeSort(new Lazy<int>(() => id), sortOrder, alias);
}
int? IWithIdBuilder.Id
{
get => _id;
set => _id = value;
}
string IWithAliasBuilder.Alias
{
get => _alias;
set => _alias = value;
}
int? IWithSortOrderBuilder.SortOrder
{
get => _sortOrder;
set => _sortOrder = value;
}
}
}
@@ -61,7 +61,7 @@ namespace Umbraco.Tests.Common.Builders
var deleteDate = _deleteDate ?? null;
var name = _name ?? Guid.NewGuid().ToString();
var level = _level ?? 0;
var path = _path ?? string.Empty;
var path = _path ?? $"-1,{id}";
var creatorId = _creatorId ?? 1;
var databaseType = _databaseType ?? ValueStorageType.Ntext;
var sortOrder = _sortOrder ?? 0;
@@ -20,6 +20,11 @@ namespace Umbraco.Tests.Common.Builders
private DateTime? _updateDate;
private string _value;
public DictionaryTranslationBuilder() : base(null)
{
_languageBuilder = new LanguageBuilder<DictionaryTranslationBuilder>(this);
}
public DictionaryTranslationBuilder(DictionaryItemBuilder parentBuilder) : base(parentBuilder)
{
_languageBuilder = new LanguageBuilder<DictionaryTranslationBuilder>(this);
@@ -0,0 +1,184 @@
using System;
using Umbraco.Core.Models.Entities;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class DocumentEntitySlimBuilder
: BuilderBase<DocumentEntitySlim>,
IWithIdBuilder,
IWithKeyBuilder,
IWithCreatorIdBuilder,
IWithCreateDateBuilder,
IWithUpdateDateBuilder,
IWithNameBuilder,
IWithLevelBuilder,
IWithPathBuilder,
IWithSortOrderBuilder,
IWithParentIdBuilder
{
private GenericDictionaryBuilder<DocumentEntitySlimBuilder, string, object> _additionalDataBuilder;
private int? _id;
private Guid? _key;
private DateTime? _createDate;
private DateTime? _updateDate;
private string _name;
private int? _creatorId;
private int? _level;
private string _path;
private int? _sortOrder;
private int? _parentId;
private string _contentTypeIcon;
private string _contentTypeThumbnail;
private string _contentTypeAlias;
private bool? _hasChildren;
private bool? _published;
public DocumentEntitySlimBuilder WithHasChildren(bool hasChildren)
{
_hasChildren = hasChildren;
return this;
}
public DocumentEntitySlimBuilder WithPublished(bool published)
{
_published = published;
return this;
}
public DocumentEntitySlimBuilder WithContentTypeAlias(string contentTypeAlias)
{
_contentTypeAlias = contentTypeAlias;
return this;
}
public DocumentEntitySlimBuilder WithContentTypeIcon(string contentTypeIcon)
{
_contentTypeIcon = contentTypeIcon;
return this;
}
public DocumentEntitySlimBuilder WithContentTypeThumbnail(string contentTypeThumbnail)
{
_contentTypeThumbnail = contentTypeThumbnail;
return this;
}
public GenericDictionaryBuilder<DocumentEntitySlimBuilder, string, object> AddAdditionalData()
{
var builder = new GenericDictionaryBuilder<DocumentEntitySlimBuilder, string, object>(this);
_additionalDataBuilder = builder;
return builder;
}
public override DocumentEntitySlim Build()
{
var id = _id ?? 1;
var key = _key ?? Guid.NewGuid();
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
var name = _name ?? Guid.NewGuid().ToString();
var creatorId = _creatorId ?? 1;
var level = _level ?? 1;
var path = _path ?? $"-1,{id}";
var sortOrder = _sortOrder ?? 0;
var parentId = _parentId ?? -1;
var icon = _contentTypeIcon ?? string.Empty;
var thumbnail = _contentTypeThumbnail ?? string.Empty;
var contentTypeAlias = _contentTypeAlias ?? string.Empty;
var hasChildren = _hasChildren ?? false;
var published = _published ?? false;
var documentEntitySlim = new DocumentEntitySlim
{
Id = id,
Key = key,
CreateDate = createDate,
UpdateDate = updateDate,
Name = name,
CreatorId = creatorId,
Level = level,
Path = path,
SortOrder = sortOrder,
ParentId = parentId,
ContentTypeIcon = icon,
ContentTypeThumbnail = thumbnail,
ContentTypeAlias = contentTypeAlias,
HasChildren = hasChildren,
Published = published,
};
if (_additionalDataBuilder != null)
{
var additionalData = _additionalDataBuilder.Build();
foreach (var kvp in additionalData)
{
documentEntitySlim.AdditionalData.Add(kvp.Key, kvp.Value);
}
}
return documentEntitySlim;
}
int? IWithIdBuilder.Id
{
get => _id;
set => _id = value;
}
Guid? IWithKeyBuilder.Key
{
get => _key;
set => _key = value;
}
int? IWithCreatorIdBuilder.CreatorId
{
get => _creatorId;
set => _creatorId = value;
}
DateTime? IWithCreateDateBuilder.CreateDate
{
get => _createDate;
set => _createDate = value;
}
DateTime? IWithUpdateDateBuilder.UpdateDate
{
get => _updateDate;
set => _updateDate = value;
}
string IWithNameBuilder.Name
{
get => _name;
set => _name = value;
}
int? IWithLevelBuilder.Level
{
get => _level;
set => _level = value;
}
string IWithPathBuilder.Path
{
get => _path;
set => _path = value;
}
int? IWithSortOrderBuilder.SortOrder
{
get => _sortOrder;
set => _sortOrder = value;
}
int? IWithParentIdBuilder.ParentId
{
get => _parentId;
set => _parentId = value;
}
}
}
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders.Extensions
@@ -178,5 +179,26 @@ namespace Umbraco.Tests.Common.Builders.Extensions
builder.LastPasswordChangeDate = lastPasswordChangeDate;
return builder;
}
public static T WithPropertyTypeIdsIncrementingFrom<T>(this T builder, int propertyTypeIdsIncrementingFrom)
where T : IWithPropertyTypeIdsIncrementingFrom
{
builder.PropertyTypeIdsIncrementingFrom = propertyTypeIdsIncrementingFrom;
return builder;
}
public static T WithIsContainer<T>(this T builder, bool isContainer)
where T : IWithIsContainerBuilder
{
builder.IsContainer = isContainer;
return builder;
}
public static T WithCultureInfo<T>(this T builder, string name)
where T : IWithCultureInfoBuilder
{
builder.CultureInfo = new CultureInfo(name);
return builder;
}
}
}
@@ -0,0 +1,110 @@
using Umbraco.Core;
using Umbraco.Core.Models;
namespace Umbraco.Tests.Common.Builders.Extensions
{
public static class ContentTypeBuilderExtensions
{
public static ContentType BuildSimpleContentType(this ContentTypeBuilder builder)
{
return (ContentType)builder
.WithId(10)
.WithAlias("textPage")
.WithName("Text Page")
.WithPropertyTypeIdsIncrementingFrom(200)
.AddPropertyGroup()
.WithName("Content")
.WithSortOrder(1)
.AddPropertyType()
.WithAlias("title")
.WithName("Title")
.WithSortOrder(1)
.Done()
.AddPropertyType()
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias("bodyText")
.WithName("Body text")
.WithSortOrder(2)
.WithDataTypeId(-87)
.Done()
.Done()
.AddPropertyGroup()
.WithName("Meta")
.WithSortOrder(2)
.AddPropertyType()
.WithAlias("keywords")
.WithName("Keywords")
.WithSortOrder(1)
.Done()
.AddPropertyType()
.WithAlias("description")
.WithName("description")
.WithSortOrder(1)
.Done()
.Done()
.AddAllowedTemplate()
.WithId(200)
.WithAlias("textPage")
.WithName("Text Page")
.Done()
.AddAllowedTemplate()
.WithId(201)
.WithAlias("textPage2")
.WithName("Text Page 2")
.Done()
.WithDefaultTemplateId(200)
.AddAllowedContentType()
.WithId(888)
.WithAlias("sub")
.WithSortOrder(8)
.Done()
.AddAllowedContentType()
.WithId(889)
.WithAlias("sub2")
.WithSortOrder(9)
.Done()
.Build();
}
public static MediaType BuildImageMediaType(this MediaTypeBuilder builder)
{
return (MediaType)builder
.WithId(10)
.WithAlias(Constants.Conventions.MediaTypes.Image)
.WithName("Image")
.WithDescription("test")
.WithIcon("icon-picture")
.WithPropertyTypeIdsIncrementingFrom(200)
.WithMediaPropertyGroup()
.Build();
}
public static MemberType BuildSimpleMemberType(this MemberTypeBuilder builder)
{
return (MemberType)builder
.WithId(10)
.WithAlias("memberType")
.WithName("Member type")
.WithIcon("icon-user-female")
.WithPropertyTypeIdsIncrementingFrom(200)
.AddPropertyGroup()
.WithName("Content")
.AddPropertyType()
.WithAlias("title")
.WithName("Title")
.WithSortOrder(1)
.Done()
.AddPropertyType()
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias("bodyText")
.WithName("Body text")
.WithSortOrder(2)
.WithDataTypeId(-87)
.Done()
.Done()
.WithMemberCanEditProperty("title", true)
.WithMemberCanViewProperty("bodyText", true)
.Build();
}
}
}
@@ -0,0 +1,6 @@
namespace Umbraco.Tests.Common.Builders.Interfaces
{
public interface IBuildContentTypes
{
}
}
@@ -0,0 +1,7 @@
namespace Umbraco.Tests.Common.Builders.Interfaces
{
public interface IWithIsContainerBuilder
{
bool? IsContainer { get; set; }
}
}
@@ -0,0 +1,7 @@
namespace Umbraco.Tests.Common.Builders.Interfaces
{
public interface IWithPropertyTypeIdsIncrementingFrom
{
int? PropertyTypeIdsIncrementingFrom { get; set; }
}
}
@@ -0,0 +1,157 @@
using System;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class MediaBuilder
: BuilderBase<Media>,
IBuildContentTypes,
IWithIdBuilder,
IWithKeyBuilder,
IWithParentIdBuilder,
IWithCreatorIdBuilder,
IWithCreateDateBuilder,
IWithUpdateDateBuilder,
IWithNameBuilder,
IWithTrashedBuilder,
IWithLevelBuilder,
IWithPathBuilder,
IWithSortOrderBuilder
{
private MediaTypeBuilder _mediaTypeBuilder;
private GenericDictionaryBuilder<MediaBuilder, string, object> _propertyDataBuilder;
private int? _id;
private Guid? _key;
private DateTime? _createDate;
private DateTime? _updateDate;
private int? _parentId;
private string _name;
private int? _creatorId;
private int? _level;
private string _path;
private int? _sortOrder;
private bool? _trashed;
public MediaTypeBuilder AddMediaType()
{
var builder = new MediaTypeBuilder(this);
_mediaTypeBuilder = builder;
return builder;
}
public override Media Build()
{
var id = _id ?? 1;
var key = _key ?? Guid.NewGuid();
var parentId = _parentId ?? -1;
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
var name = _name ?? Guid.NewGuid().ToString();
var creatorId = _creatorId ?? 1;
var level = _level ?? 1;
var path = _path ?? $"-1,{id}";
var sortOrder = _sortOrder ?? 0;
var trashed = _trashed ?? false;
if (_mediaTypeBuilder == null)
{
throw new InvalidOperationException("A member cannot be constructed without providing a member type. Use AddMediaType().");
}
var memberType = _mediaTypeBuilder.Build();
var member = new Media(name, parentId, memberType)
{
Id = id,
Key = key,
CreateDate = createDate,
UpdateDate = updateDate,
CreatorId = creatorId,
Level = level,
Path = path,
SortOrder = sortOrder,
Trashed = trashed,
};
if (_propertyDataBuilder != null)
{
var propertyData = _propertyDataBuilder.Build();
foreach (var kvp in propertyData)
{
member.SetValue(kvp.Key, kvp.Value);
}
member.ResetDirtyProperties(false);
}
return member;
}
int? IWithIdBuilder.Id
{
get => _id;
set => _id = value;
}
Guid? IWithKeyBuilder.Key
{
get => _key;
set => _key = value;
}
int? IWithCreatorIdBuilder.CreatorId
{
get => _creatorId;
set => _creatorId = value;
}
DateTime? IWithCreateDateBuilder.CreateDate
{
get => _createDate;
set => _createDate = value;
}
DateTime? IWithUpdateDateBuilder.UpdateDate
{
get => _updateDate;
set => _updateDate = value;
}
string IWithNameBuilder.Name
{
get => _name;
set => _name = value;
}
bool? IWithTrashedBuilder.Trashed
{
get => _trashed;
set => _trashed = value;
}
int? IWithLevelBuilder.Level
{
get => _level;
set => _level = value;
}
string IWithPathBuilder.Path
{
get => _path;
set => _path = value;
}
int? IWithSortOrderBuilder.SortOrder
{
get => _sortOrder;
set => _sortOrder = value;
}
int? IWithParentIdBuilder.ParentId
{
get => _parentId;
set => _parentId = value;
}
}
}
@@ -0,0 +1,117 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class MediaTypeBuilder
: ContentTypeBaseBuilder<MediaBuilder, IMediaType>,
IWithPropertyTypeIdsIncrementingFrom
{
private List<PropertyGroupBuilder<MediaTypeBuilder>> _propertyGroupBuilders = new List<PropertyGroupBuilder<MediaTypeBuilder>>();
private int? _propertyTypeIdsIncrementingFrom;
public MediaTypeBuilder() : base(null)
{
}
public MediaTypeBuilder(MediaBuilder parentBuilder) : base(parentBuilder)
{
}
public MediaTypeBuilder WithMediaPropertyGroup()
{
var builder = new PropertyGroupBuilder<MediaTypeBuilder>(this)
.WithId(99)
.WithName("Media")
.WithSortOrder(1)
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.UploadField)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias(Constants.Conventions.Media.File)
.WithName("File")
.WithSortOrder(1)
.WithDataTypeId(-90)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Label)
.WithValueStorageType(ValueStorageType.Integer)
.WithAlias(Constants.Conventions.Media.Width)
.WithName("Width")
.WithSortOrder(2)
.WithDataTypeId(Constants.System.DefaultLabelDataTypeId)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Label)
.WithValueStorageType(ValueStorageType.Integer)
.WithAlias(Constants.Conventions.Media.Height)
.WithName("Height")
.WithSortOrder(3)
.WithDataTypeId(Constants.System.DefaultLabelDataTypeId)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Label)
.WithValueStorageType(ValueStorageType.Integer)
.WithAlias(Constants.Conventions.Media.Bytes)
.WithName("Bytes")
.WithSortOrder(4)
.WithDataTypeId(Constants.System.DefaultLabelDataTypeId)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Label)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias(Constants.Conventions.Media.Extension)
.WithName("File Extension")
.WithSortOrder(5)
.WithDataTypeId(Constants.System.DefaultLabelDataTypeId)
.Done();
_propertyGroupBuilders.Add(builder);
return this;
}
public PropertyGroupBuilder<MediaTypeBuilder> AddPropertyGroup()
{
var builder = new PropertyGroupBuilder<MediaTypeBuilder>(this);
_propertyGroupBuilders.Add(builder);
return builder;
}
public override IMediaType Build()
{
var mediaType = new MediaType(ShortStringHelper, GetParentId())
{
Id = GetId(),
Key = GetKey(),
CreateDate = GetCreateDate(),
UpdateDate = GetUpdateDate(),
Alias = GetAlias(),
Name = GetName(),
Level = GetLevel(),
Path = GetPath(),
SortOrder = GetSortOrder(),
Description = GetDescription(),
Icon = GetIcon(),
Thumbnail = GetThumbnail(),
CreatorId = GetCreatorId(),
Trashed = GetTrashed(),
IsContainer = GetIsContainer(),
};
BuildPropertyGroups(mediaType, _propertyGroupBuilders.Select(x => x.Build()));
BuildPropertyTypeIds(mediaType, _propertyTypeIdsIncrementingFrom);
mediaType.ResetDirtyProperties(false);
return mediaType;
}
int? IWithPropertyTypeIdsIncrementingFrom.PropertyTypeIdsIncrementingFrom
{
get => _propertyTypeIdsIncrementingFrom;
set => _propertyTypeIdsIncrementingFrom = value;
}
}
}
@@ -6,6 +6,7 @@ namespace Umbraco.Tests.Common.Builders
{
public class MemberBuilder
: BuilderBase<Member>,
IBuildContentTypes,
IWithIdBuilder,
IWithKeyBuilder,
IWithCreatorIdBuilder,
@@ -87,7 +88,7 @@ namespace Umbraco.Tests.Common.Builders
var name = _name ?? Guid.NewGuid().ToString();
var creatorId = _creatorId ?? 1;
var level = _level ?? 1;
var path = _path ?? "-1";
var path = _path ?? $"-1,{id}";
var sortOrder = _sortOrder ?? 0;
var trashed = _trashed ?? false;
var username = _username ?? string.Empty;
@@ -3,38 +3,23 @@ using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Strings;
using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class MemberTypeBuilder
: ChildBuilderBase<MemberBuilder, IMemberType>,
IBuildPropertyGroups,
IWithIdBuilder,
IWithAliasBuilder,
IWithNameBuilder,
IWithParentIdBuilder,
IWithSortOrderBuilder,
IWithCreatorIdBuilder,
IWithDescriptionBuilder,
IWithIconBuilder,
IWithThumbnailBuilder,
IWithTrashedBuilder
: ContentTypeBaseBuilder<MemberBuilder, IMemberType>,
IWithPropertyTypeIdsIncrementingFrom
{
private readonly List<PropertyGroupBuilder<MemberTypeBuilder>> _propertyGroupBuilders = new List<PropertyGroupBuilder<MemberTypeBuilder>>();
private List<PropertyGroupBuilder<MemberTypeBuilder>> _propertyGroupBuilders = new List<PropertyGroupBuilder<MemberTypeBuilder>>();
private Dictionary<string, bool> _memberCanEditProperties = new Dictionary<string, bool>();
private Dictionary<string, bool> _memberCanViewProperties = new Dictionary<string, bool>();
private int? _propertyTypeIdsIncrementingFrom;
private int? _id;
private string _alias;
private string _name;
private int? _parentId;
private int? _sortOrder;
private int? _creatorId;
private string _description;
private string _icon;
private string _thumbnail;
private bool? _trashed;
public MemberTypeBuilder() : base(null)
{
}
public MemberTypeBuilder(MemberBuilder parentBuilder) : base(parentBuilder)
{
@@ -45,7 +30,6 @@ namespace Umbraco.Tests.Common.Builders
var builder = new PropertyGroupBuilder<MemberTypeBuilder>(this)
.WithId(99)
.WithName(Constants.Conventions.Member.StandardPropertiesGroupName)
.WithSortOrder(1)
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextArea)
.WithValueStorageType(ValueStorageType.Ntext)
@@ -92,6 +76,18 @@ namespace Umbraco.Tests.Common.Builders
return this;
}
public MemberTypeBuilder WithMemberCanEditProperty(string alias, bool canEdit)
{
_memberCanEditProperties.Add(alias, canEdit);
return this;
}
public MemberTypeBuilder WithMemberCanViewProperty(string alias, bool canView)
{
_memberCanViewProperties.Add(alias, canView);
return this;
}
public PropertyGroupBuilder<MemberTypeBuilder> AddPropertyGroup()
{
var builder = new PropertyGroupBuilder<MemberTypeBuilder>(this);
@@ -101,35 +97,36 @@ namespace Umbraco.Tests.Common.Builders
public override IMemberType Build()
{
var id = _id ?? 1;
var name = _name ?? Guid.NewGuid().ToString();
var alias = _alias ?? name.ToCamelCase();
var parentId = _parentId ?? -1;
var sortOrder = _sortOrder ?? 0;
var description = _description ?? string.Empty;
var icon = _icon ?? string.Empty;
var thumbnail = _thumbnail ?? string.Empty;
var creatorId = _creatorId ?? 0;
var trashed = _trashed ?? false;
var shortStringHelper = new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
var memberType = new MemberType(shortStringHelper, parentId)
var memberType = new MemberType(ShortStringHelper, GetParentId())
{
Id = id,
Alias = alias,
Name = name,
SortOrder = sortOrder,
Description = description,
Icon = icon,
Thumbnail = thumbnail,
CreatorId = creatorId,
Trashed = trashed,
Id = GetId(),
Key = GetKey(),
CreateDate = GetCreateDate(),
UpdateDate = GetUpdateDate(),
Alias = GetAlias(),
Name = GetName(),
Level = GetLevel(),
Path = GetPath(),
SortOrder = GetSortOrder(),
Description = GetDescription(),
Icon = GetIcon(),
Thumbnail = GetThumbnail(),
CreatorId = GetCreatorId(),
Trashed = GetTrashed(),
IsContainer = GetIsContainer(),
};
foreach (var propertyGroup in _propertyGroupBuilders.Select(x => x.Build()))
BuildPropertyGroups(memberType, _propertyGroupBuilders.Select(x => x.Build()));
BuildPropertyTypeIds(memberType, _propertyTypeIdsIncrementingFrom);
foreach (var kvp in _memberCanEditProperties)
{
memberType.PropertyGroups.Add(propertyGroup);
memberType.SetMemberCanEditProperty(kvp.Key, kvp.Value);
}
foreach (var kvp in _memberCanViewProperties)
{
memberType.SetMemberCanViewProperty(kvp.Key, kvp.Value);
}
memberType.ResetDirtyProperties(false);
@@ -137,64 +134,10 @@ namespace Umbraco.Tests.Common.Builders
return memberType;
}
int? IWithIdBuilder.Id
int? IWithPropertyTypeIdsIncrementingFrom.PropertyTypeIdsIncrementingFrom
{
get => _id;
set => _id = value;
}
string IWithAliasBuilder.Alias
{
get => _alias;
set => _alias = value;
}
string IWithNameBuilder.Name
{
get => _name;
set => _name = value;
}
int? IWithParentIdBuilder.ParentId
{
get => _parentId;
set => _parentId = value;
}
int? IWithSortOrderBuilder.SortOrder
{
get => _sortOrder;
set => _sortOrder = value;
}
int? IWithCreatorIdBuilder.CreatorId
{
get => _creatorId;
set => _creatorId = value;
}
string IWithDescriptionBuilder.Description
{
get => _description;
set => _description = value;
}
string IWithIconBuilder.Icon
{
get => _icon;
set => _icon = value;
}
string IWithThumbnailBuilder.Thumbnail
{
get => _thumbnail;
set => _thumbnail = value;
}
bool? IWithTrashedBuilder.Trashed
{
get => _trashed;
set => _trashed = value;
get => _propertyTypeIdsIncrementingFrom;
set => _propertyTypeIdsIncrementingFrom = value;
}
}
}
@@ -1,4 +1,5 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Strings;
using Umbraco.Tests.Common.Builders.Extensions;
@@ -91,14 +92,14 @@ namespace Umbraco.Tests.Common.Builders
{
var id = _id ?? 0;
var key = _key ?? Guid.NewGuid();
var propertyEditorAlias = _propertyEditorAlias ?? Guid.NewGuid().ToString().ToCamelCase();
var valueStorageType = _valueStorageType ?? ValueStorageType.Ntext;
var propertyEditorAlias = _propertyEditorAlias ?? Constants.PropertyEditors.Aliases.TextBox;
var valueStorageType = _valueStorageType ?? ValueStorageType.Nvarchar;
var name = _name ?? Guid.NewGuid().ToString();
var alias = _alias ?? name.ToCamelCase();
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
var sortOrder = _sortOrder ?? 0;
var dataTypeId = _dataTypeId ?? 0;
var dataTypeId = _dataTypeId ?? -88;
var description = _description ?? string.Empty;
var propertyGroupId = _propertyGroupId ?? null;
var mandatory = _mandatory ?? false;
@@ -7,7 +7,7 @@ using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
{
public class TemplateBuilder
: BuilderBase<Template>,
: ChildBuilderBase<ContentTypeBuilder, ITemplate>,
IWithIdBuilder,
IWithKeyBuilder,
IWithAliasBuilder,
@@ -28,6 +28,14 @@ namespace Umbraco.Tests.Common.Builders
private string _masterTemplateAlias;
private Lazy<int> _masterTemplateId;
public TemplateBuilder() : base(null)
{
}
public TemplateBuilder(ContentTypeBuilder parentBuilder) : base(parentBuilder)
{
}
public TemplateBuilder WithContent(string content)
{
_content = content;
@@ -42,7 +50,7 @@ namespace Umbraco.Tests.Common.Builders
return this;
}
public override Template Build()
public override ITemplate Build()
{
var id = _id ?? 0;
var key = _key ?? Guid.NewGuid();
@@ -50,7 +58,7 @@ namespace Umbraco.Tests.Common.Builders
var alias = _alias ?? name.ToCamelCase();
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
var path = _path ?? string.Empty;
var path = _path ?? $"-1,{id}";
var content = _content;
var isMasterTemplate = _isMasterTemplate ?? false;
var masterTemplateAlias = _masterTemplateAlias ?? string.Empty;
@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using Moq;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Strings;
using Umbraco.Tests.Common.Builders.Interfaces;
namespace Umbraco.Tests.Common.Builders
@@ -20,15 +21,16 @@ namespace Umbraco.Tests.Common.Builders
IWithAliasBuilder,
IWithNameBuilder
{
private int? _startContentId;
private int? _startMediaId;
private int? _id;
private string _alias;
private string _icon;
private string _name;
private IEnumerable<string> _permissions = Enumerable.Empty<string>();
private IEnumerable<string> _sectionCollection = Enumerable.Empty<string>();
private string _suffix;
private int? _id;
private int? _startContentId;
private int? _startMediaId;
private int? _userCount;
public UserGroupBuilder(TParent parentBuilder) : base(parentBuilder)
{
@@ -45,6 +47,36 @@ namespace Umbraco.Tests.Common.Builders
return this;
}
public UserGroupBuilder<TParent> WithUserCount(int userCount)
{
_userCount = userCount;
return this;
}
public UserGroupBuilder<TParent> WithPermissions(string permissions)
{
_permissions = permissions.Split();
return this;
}
public UserGroupBuilder<TParent> WithPermissions(IList<string> permissions)
{
_permissions = permissions;
return this;
}
public UserGroupBuilder<TParent> WithStartContentId(int startContentId)
{
_startContentId = startContentId;
return this;
}
public UserGroupBuilder<TParent> WithStartMediaId(int startMediaId)
{
_startMediaId = startMediaId;
return this;
}
public IReadOnlyUserGroup BuildReadOnly(IUserGroup userGroup)
{
return Mock.Of<IReadOnlyUserGroup>(x =>
@@ -60,14 +92,26 @@ namespace Umbraco.Tests.Common.Builders
public override IUserGroup Build()
{
var userGroup = Mock.Of<IUserGroup>(x =>
x.StartContentId == _startContentId &&
x.StartMediaId == _startMediaId &&
x.Name == (_name ?? ("TestUserGroup" + _suffix)) &&
x.Alias == (_alias ?? ("testUserGroup" + _suffix)) &&
x.Icon == _icon &&
x.Permissions == _permissions &&
x.AllowedSections == _sectionCollection);
var id = _id ?? 1;
var name = _name ?? ("TestUserGroup" + _suffix);
var alias = _alias ?? ("testUserGroup" + _suffix);
var userCount = _userCount ?? 0;
var startContentId = _startContentId ?? -1;
var startMediaId = _startMediaId ?? -1;
var icon = _icon ?? "icon-group";
var shortStringHelper = new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
var userGroup = new UserGroup(shortStringHelper, userCount, alias, name, _permissions, icon);
userGroup.Id = id;
userGroup.StartContentId = startContentId;
userGroup.StartMediaId = startMediaId;
foreach (var item in _sectionCollection)
{
userGroup.AddAllowedSection(item);
}
return userGroup;
}
@@ -77,7 +121,6 @@ namespace Umbraco.Tests.Common.Builders
set => _id = value;
}
string IWithIconBuilder.Icon
{
get => _icon;
@@ -7,7 +7,7 @@ using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Tests.Mapping
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Mapping
{
[TestFixture]
public class MappingTests
@@ -138,7 +138,6 @@ namespace Umbraco.Tests.Mapping
{
// keep failing at mapping - and looping through the maps
for (var i = 0; i < 10; i++)
{
try
{
mapper.Map<Thing2>(thing4);
@@ -148,7 +147,6 @@ namespace Umbraco.Tests.Mapping
caught = e;
Console.WriteLine($"{e.GetType().Name} {e.Message}");
}
}
Console.WriteLine("done");
}
@@ -185,7 +183,7 @@ namespace Umbraco.Tests.Mapping
{
Fruit1 = Thing5Enum.Apple,
Fruit2 = Thing5Enum.Banana,
Fruit3= Thing5Enum.Cherry
Fruit3 = Thing5Enum.Cherry
};
var thing6 = mapper.Map<Thing5, Thing6>(thing5);
@@ -3,7 +3,7 @@ using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Models;
namespace Umbraco.Tests.Models
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
{
[TestFixture]
public class ContentScheduleTests
@@ -0,0 +1,302 @@
using System;
using System.Diagnostics;
using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
{
[TestFixture]
public class ContentTypeTests
{
[Test]
[Ignore("Ignoring this test until we actually enforce this, see comments in ContentTypeBase.PropertyTypesChanged")]
public void Cannot_Add_Duplicate_Property_Aliases()
{
var contentType = BuildContentType();
var propertyTypeBuilder = new PropertyTypeBuilder();
var additionalPropertyType = propertyTypeBuilder
.WithAlias("title")
.Build();
Assert.Throws<InvalidOperationException>(() =>
contentType.PropertyTypeCollection.Add(additionalPropertyType));
}
[Test]
[Ignore("Ignoring this test until we actually enforce this, see comments in ContentTypeBase.PropertyTypesChanged")]
public void Cannot_Update_Duplicate_Property_Aliases()
{
var contentType = BuildContentType();
var propertyTypeBuilder = new PropertyTypeBuilder();
var additionalPropertyType = propertyTypeBuilder
.WithAlias("title")
.Build();
contentType.PropertyTypeCollection.Add(additionalPropertyType);
var toUpdate = contentType.PropertyTypeCollection["myPropertyType2"];
Assert.Throws<InvalidOperationException>(() => toUpdate.Alias = "myPropertyType");
}
[Test]
public void Can_Deep_Clone_Content_Type_Sort()
{
var contentType = BuildContentTypeSort();
var clone = (ContentTypeSort)contentType.DeepClone();
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id.Value, contentType.Id.Value);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreEqual(clone.Alias, contentType.Alias);
}
private ContentTypeSort BuildContentTypeSort()
{
var builder = new ContentTypeSortBuilder();
return builder
.WithId(3)
.WithSortOrder(4)
.WithAlias("test")
.Build();
}
[Test]
public void Can_Deep_Clone_Content_Type_With_Reset_Identities()
{
var contentType = BuildContentType();
var clone = (ContentType)contentType.DeepCloneWithResetIdentities("newAlias");
Assert.AreEqual("newAlias", clone.Alias);
Assert.AreNotEqual("newAlias", contentType.Alias);
Assert.IsFalse(clone.HasIdentity);
foreach (var propertyGroup in clone.PropertyGroups)
{
Assert.IsFalse(propertyGroup.HasIdentity);
foreach (var propertyType in propertyGroup.PropertyTypes)
Assert.IsFalse(propertyType.HasIdentity);
}
foreach (var propertyType in clone.PropertyTypes.Where(x => x.HasIdentity))
Assert.IsFalse(propertyType.HasIdentity);
}
[Test]
public void Can_Deep_Clone_Content_Type()
{
// Arrange
var contentType = BuildContentType();
// Act
var clone = (ContentType)contentType.DeepClone();
// Assert
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id, contentType.Id);
Assert.AreEqual(clone.AllowedTemplates.Count(), contentType.AllowedTemplates.Count());
for (var index = 0; index < contentType.AllowedTemplates.Count(); index++)
{
Assert.AreNotSame(clone.AllowedTemplates.ElementAt(index), contentType.AllowedTemplates.ElementAt(index));
Assert.AreEqual(clone.AllowedTemplates.ElementAt(index), contentType.AllowedTemplates.ElementAt(index));
}
Assert.AreNotSame(clone.PropertyGroups, contentType.PropertyGroups);
Assert.AreEqual(clone.PropertyGroups.Count, contentType.PropertyGroups.Count);
for (var index = 0; index < contentType.PropertyGroups.Count; index++)
{
Assert.AreNotSame(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
Assert.AreEqual(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
}
Assert.AreNotSame(clone.PropertyTypes, contentType.PropertyTypes);
Assert.AreEqual(clone.PropertyTypes.Count(), contentType.PropertyTypes.Count());
Assert.AreEqual(0, clone.NoGroupPropertyTypes.Count());
for (var index = 0; index < contentType.PropertyTypes.Count(); index++)
{
Assert.AreNotSame(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
Assert.AreEqual(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
}
Assert.AreEqual(clone.CreateDate, contentType.CreateDate);
Assert.AreEqual(clone.CreatorId, contentType.CreatorId);
Assert.AreEqual(clone.Key, contentType.Key);
Assert.AreEqual(clone.Level, contentType.Level);
Assert.AreEqual(clone.Path, contentType.Path);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreNotSame(clone.DefaultTemplate, contentType.DefaultTemplate);
Assert.AreEqual(clone.DefaultTemplate, contentType.DefaultTemplate);
Assert.AreEqual(clone.DefaultTemplateId, contentType.DefaultTemplateId);
Assert.AreEqual(clone.Trashed, contentType.Trashed);
Assert.AreEqual(clone.UpdateDate, contentType.UpdateDate);
Assert.AreEqual(clone.Thumbnail, contentType.Thumbnail);
Assert.AreEqual(clone.Icon, contentType.Icon);
Assert.AreEqual(clone.IsContainer, contentType.IsContainer);
//This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(contentType, null));
//need to ensure the event handlers are wired
var asDirty = (ICanBeDirty)clone;
Assert.IsFalse(asDirty.IsPropertyDirty("PropertyTypes"));
var propertyTypeBuilder = new PropertyTypeBuilder();
var additionalPropertyType = propertyTypeBuilder
.WithAlias("blah")
.Build();
clone.AddPropertyType(additionalPropertyType);
Assert.IsTrue(asDirty.IsPropertyDirty("PropertyTypes"));
Assert.IsFalse(asDirty.IsPropertyDirty("PropertyGroups"));
clone.AddPropertyGroup("hello");
Assert.IsTrue(asDirty.IsPropertyDirty("PropertyGroups"));
}
[Test]
public void Can_Serialize_Content_Type_Without_Error()
{
// Arrange
var contentType = BuildContentType();
var json = JsonConvert.SerializeObject(contentType);
Debug.Print(json);
}
private static ContentType BuildContentType()
{
var builder = new ContentTypeBuilder();
return builder.BuildSimpleContentType();
}
[Test]
public void Can_Deep_Clone_Media_Type()
{
// Arrange
var contentType = BuildMediaType();
// Act
var clone = (MediaType)contentType.DeepClone();
// Assert
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id, contentType.Id);
Assert.AreEqual(clone.PropertyGroups.Count, contentType.PropertyGroups.Count);
for (var index = 0; index < contentType.PropertyGroups.Count; index++)
{
Assert.AreNotSame(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
Assert.AreEqual(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
}
Assert.AreEqual(clone.PropertyTypes.Count(), contentType.PropertyTypes.Count());
for (var index = 0; index < contentType.PropertyTypes.Count(); index++)
{
Assert.AreNotSame(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
Assert.AreEqual(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
}
Assert.AreEqual(clone.CreateDate, contentType.CreateDate);
Assert.AreEqual(clone.CreatorId, contentType.CreatorId);
Assert.AreEqual(clone.Key, contentType.Key);
Assert.AreEqual(clone.Level, contentType.Level);
Assert.AreEqual(clone.Path, contentType.Path);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreEqual(clone.Trashed, contentType.Trashed);
Assert.AreEqual(clone.UpdateDate, contentType.UpdateDate);
Assert.AreEqual(clone.Thumbnail, contentType.Thumbnail);
Assert.AreEqual(clone.Icon, contentType.Icon);
Assert.AreEqual(clone.IsContainer, contentType.IsContainer);
//This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(contentType, null));
}
[Test]
public void Can_Serialize_Media_Type_Without_Error()
{
// Arrange
var contentType = BuildMediaType();
var json = JsonConvert.SerializeObject(contentType);
Debug.Print(json);
}
private static MediaType BuildMediaType()
{
var builder = new MediaTypeBuilder();
return builder.BuildImageMediaType();
}
[Test]
public void Can_Deep_Clone_Member_Type()
{
// Arrange
var contentType = BuildMemberType();
// Act
var clone = (MemberType)contentType.DeepClone();
// Assert
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id, contentType.Id);
Assert.AreEqual(clone.PropertyGroups.Count, contentType.PropertyGroups.Count);
for (var index = 0; index < contentType.PropertyGroups.Count; index++)
{
Assert.AreNotSame(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
Assert.AreEqual(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
}
Assert.AreEqual(clone.PropertyTypes.Count(), contentType.PropertyTypes.Count());
for (var index = 0; index < contentType.PropertyTypes.Count(); index++)
{
Assert.AreNotSame(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
Assert.AreEqual(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
}
Assert.AreEqual(clone.CreateDate, contentType.CreateDate);
Assert.AreEqual(clone.CreatorId, contentType.CreatorId);
Assert.AreEqual(clone.Key, contentType.Key);
Assert.AreEqual(clone.Level, contentType.Level);
Assert.AreEqual(clone.Path, contentType.Path);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreEqual(clone.Trashed, contentType.Trashed);
Assert.AreEqual(clone.UpdateDate, contentType.UpdateDate);
Assert.AreEqual(clone.Thumbnail, contentType.Thumbnail);
Assert.AreEqual(clone.Icon, contentType.Icon);
Assert.AreEqual(clone.IsContainer, contentType.IsContainer);
Assert.AreEqual(clone.MemberTypePropertyTypes, contentType.MemberTypePropertyTypes);
// This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(contentType, null));
}
[Test]
public void Can_Serialize_Member_Type_Without_Error()
{
// Arrange
var contentType = BuildMemberType();
var json = JsonConvert.SerializeObject(contentType);
Debug.Print(json);
}
private static MemberType BuildMemberType()
{
var builder = new MemberTypeBuilder();
return builder.BuildSimpleMemberType();
}
}
}
@@ -2,7 +2,7 @@
using NUnit.Framework;
using Umbraco.Core.Models;
namespace Umbraco.Tests.Models
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
{
[TestFixture]
public class CultureImpactTests
@@ -5,7 +5,7 @@ using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Models;
namespace Umbraco.Tests.Models
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
{
[TestFixture]
public class DeepCloneHelperTests
@@ -38,7 +38,7 @@ namespace Umbraco.Tests.Models
Assert.AreNotSame(test1, clone);
Assert.AreEqual(test1.MyTest1.Length, clone.MyTest1.Length);
for (int i = 0; i < test1.MyTest1.Length; i++)
for (var i = 0; i < test1.MyTest1.Length; i++)
{
Assert.IsNotNull(clone.MyTest1.ElementAt(i));
Assert.AreNotSame(clone.MyTest1.ElementAt(i), test1.MyTest1.ElementAt(i));
@@ -57,7 +57,7 @@ namespace Umbraco.Tests.Models
Assert.AreNotSame(test1, clone);
Assert.AreEqual(test1.MyTest1.Length, clone.MyTest1.Length);
for (int i = 0; i < test1.MyTest1.Length; i++)
for (var i = 0; i < test1.MyTest1.Length; i++)
{
Assert.IsNotNull(clone.MyTest1.ElementAt(i));
Assert.AreNotSame(clone.MyTest1.ElementAt(i), test1.MyTest1.ElementAt(i));
@@ -77,7 +77,7 @@ namespace Umbraco.Tests.Models
Assert.AreNotSame(test1, clone);
Assert.AreEqual(test1.MyTest1.Cast<object>().Count(), clone.MyTest1.Cast<object>().Count());
for (int i = 0; i < test1.MyTest1.Cast<object>().Count(); i++)
for (var i = 0; i < test1.MyTest1.Cast<object>().Count(); i++)
{
Assert.IsNotNull(clone.MyTest1.Cast<object>().ElementAt(i));
Assert.AreNotSame(clone.MyTest1.Cast<object>().ElementAt(i), test1.MyTest1.Cast<object>().ElementAt(i));
@@ -96,7 +96,7 @@ namespace Umbraco.Tests.Models
Assert.AreNotSame(test1, clone);
Assert.AreEqual(test1.MyTest1.Count(), clone.MyTest1.Count());
for (int i = 0; i < test1.MyTest1.Count(); i++)
for (var i = 0; i < test1.MyTest1.Count(); i++)
{
Assert.IsNotNull(clone.MyTest1.ElementAt(i));
Assert.AreNotSame(clone.MyTest1.ElementAt(i), test1.MyTest1.ElementAt(i));
@@ -115,7 +115,7 @@ namespace Umbraco.Tests.Models
Assert.AreNotSame(test1, clone);
Assert.AreEqual(test1.MyTest1.Count(), clone.MyTest1.Count());
for (int i = 0; i < test1.MyTest1.Count(); i++)
for (var i = 0; i < test1.MyTest1.Count(); i++)
{
Assert.IsNotNull(clone.MyTest1.ElementAt(i));
Assert.AreNotSame(clone.MyTest1.ElementAt(i), test1.MyTest1.ElementAt(i));
@@ -134,7 +134,7 @@ namespace Umbraco.Tests.Models
Assert.AreNotSame(test1, clone);
Assert.AreEqual(test1.MyTest1.Count(), clone.MyTest1.Count());
for (int i = 0; i < test1.MyTest1.Count(); i++)
for (var i = 0; i < test1.MyTest1.Count(); i++)
{
Assert.IsNotNull(clone.MyTest1.ElementAt(i));
Assert.AreNotSame(clone.MyTest1.ElementAt(i), test1.MyTest1.ElementAt(i));
@@ -1,41 +1,30 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.Serialization;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.Models
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
{
[TestFixture]
public class DictionaryTranslationTests
{
private IGlobalSettings GlobalSettings { get; } = SettingsForTests.GenerateMockGlobalSettings();
private DictionaryTranslationBuilder _builder = new DictionaryTranslationBuilder();
[SetUp]
public void SetUp()
{
_builder = new DictionaryTranslationBuilder();
}
[Test]
public void Can_Deep_Clone()
{
var item = new DictionaryTranslation(new Language(GlobalSettings, "en-AU")
{
CreateDate = DateTime.Now,
CultureName = "en",
Id = 11,
IsoCode = "AU",
Key = Guid.NewGuid(),
UpdateDate = DateTime.Now
}, "colour")
{
CreateDate = DateTime.Now,
Id = 88,
Key = Guid.NewGuid(),
UpdateDate = DateTime.Now
};
var item = BuildDictionaryTranslation();
var clone = (DictionaryTranslation) item.DeepClone();
var clone = (DictionaryTranslation)item.DeepClone();
Assert.AreNotSame(clone, item);
Assert.AreEqual(clone, item);
@@ -53,32 +42,26 @@ namespace Umbraco.Tests.Models
//This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps.Where(x => x.Name != "Language"))
{
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(item, null));
}
}
[Test]
public void Can_Serialize_Without_Error()
{
var item = new DictionaryTranslation(new Language(GlobalSettings, "en-AU")
{
CreateDate = DateTime.Now,
CultureName = "en",
Id = 11,
IsoCode = "AU",
Key = Guid.NewGuid(),
UpdateDate = DateTime.Now
}, "colour")
{
CreateDate = DateTime.Now,
Id = 88,
Key = Guid.NewGuid(),
UpdateDate = DateTime.Now
};
var item = BuildDictionaryTranslation();
var json = JsonConvert.SerializeObject(item);
Debug.Print(json);
}
private IDictionaryTranslation BuildDictionaryTranslation()
{
return _builder
.AddLanguage()
.WithCultureInfo("en-AU")
.Done()
.WithValue("colour")
.Build();
}
}
}
@@ -0,0 +1,45 @@
using System.Diagnostics;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
{
[TestFixture]
public class DocumentEntityTests
{
private DocumentEntitySlimBuilder _builder;
[SetUp]
public void SetUp()
{
_builder = new DocumentEntitySlimBuilder();
}
[Test]
public void Can_Serialize_Without_Error()
{
var item = _builder
.WithId(3)
.WithCreatorId(4)
.WithName("Test")
.WithParentId(5)
.WithSortOrder(6)
.WithLevel(7)
.WithContentTypeAlias("test1")
.WithContentTypeIcon("icon")
.WithContentTypeThumbnail("thumb")
.WithHasChildren(true)
.WithPublished(true)
.AddAdditionalData()
.WithKeyValue("test1", 3)
.WithKeyValue("test2", "value")
.Done()
.Build();
var json = JsonConvert.SerializeObject(item);
Debug.Print(json);
}
}
}
@@ -93,17 +93,12 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
.WithMembershipPropertyGroup()
.AddPropertyGroup()
.WithName("Content")
.WithSortOrder(1)
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias("title")
.WithName("Title")
.WithSortOrder(1)
.WithDataTypeId(-88)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias("bodyText")
.WithName("Body text")
@@ -111,13 +106,10 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
.WithDataTypeId(-87)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias("author")
.WithName("Author")
.WithDescription("Name of the author")
.WithSortOrder(3)
.WithDataTypeId(-88)
.Done()
.Done()
.Done()
@@ -125,13 +117,9 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
.WithName("Fred")
.WithLogin("fred", "raw pass")
.WithEmail("email@email.com")
.WithCreatorId(22)
.WithFailedPasswordAttempts(22)
.WithLevel(3)
.WithPath("-1, 4, 10")
.WithIsApproved(true)
.WithIsLockedOut(true)
.WithSortOrder(5)
.WithTrashed(false)
.AddMemberGroups()
.WithValue("Group 1")
@@ -65,15 +65,10 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
return _builder
.WithId(77)
.WithName("Group1")
.WithSortOrder(555)
.AddPropertyType()
.WithId(3)
.WithPropertyEditorAlias("TestPropertyEditor")
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias("test")
.WithName("Test")
.WithSortOrder(9)
.WithDataTypeId(5)
.WithDescription("testing")
.WithPropertyGroupId(11)
.WithMandatory(true)
@@ -81,16 +76,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
.Done()
.AddPropertyType()
.WithId(4)
.WithPropertyEditorAlias("TestPropertyEditor2")
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias("test2")
.WithName("Test2")
.WithSortOrder(10)
.WithDataTypeId(6)
.WithDescription("testing2")
.WithPropertyGroupId(12)
.WithMandatory(true)
.WithValidationRegExp("yyyy")
.WithName("Test2")
.Done()
.Build();
}
@@ -51,7 +51,6 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
.AddPropertyType()
.WithId(3)
.WithPropertyEditorAlias("TestPropertyEditor")
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias("test")
.WithName("Test")
.WithSortOrder(9)
@@ -75,7 +75,6 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
return _builder
.WithId(3)
.WithPropertyEditorAlias("TestPropertyEditor")
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias("test")
.WithName("Test")
.WithSortOrder(9)
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
Assert.AreEqual(clone.Id, template.Id);
Assert.AreEqual(clone.Key, template.Key);
Assert.AreEqual(clone.MasterTemplateAlias, template.MasterTemplateAlias);
Assert.AreEqual(clone.MasterTemplateId.Value, template.MasterTemplateId.Value);
Assert.AreEqual(clone.MasterTemplateId.Value, ((Template)template).MasterTemplateId.Value);
Assert.AreEqual(clone.Name, template.Name);
Assert.AreEqual(clone.UpdateDate, template.UpdateDate);
@@ -65,7 +65,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
Debug.Print(json);
}
private Template BuildTemplate()
private ITemplate BuildTemplate()
{
return _builder
.WithId(3)
@@ -74,7 +74,6 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Models
.WithCreateDate(DateTime.Now)
.WithUpdateDate(DateTime.Now)
.WithKey(Guid.NewGuid())
.WithPath("-1,3")
.WithContent("blah")
.AsMasterTemplate("master", 88)
.Build();
@@ -0,0 +1,11 @@
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
public class AllowedContentTypeDetail
{
public int Id { get; set; }
public string Alias { get; set; }
public int SortOrder { get; set; }
}
}
@@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
[TestFixture]
public class ContentTypeBuilderTests
{
[Test]
public void Is_Built_Correctly()
{
// Arrange
const int testId = 99;
var testKey = Guid.NewGuid();
const string testAlias = "mediaType";
const string testName = "Content Type";
const string testPropertyGroupName = "Content";
const int testParentId = 98;
const int testCreatorId = 22;
var testCreateDate = DateTime.Now.AddHours(-1);
var testUpdateDate = DateTime.Now;
const int testLevel = 3;
const string testPath = "-1, 4, 10";
const int testSortOrder = 5;
const string testDescription = "The description";
const string testIcon = "icon";
const string testThumbnail = "thumnail";
const bool testTrashed = true;
const int testPropertyTypeIdsIncrementingFrom = 200;
var testPropertyType1 = new PropertyTypeDetail { Alias = "title", Name = "Title", SortOrder = 1, DataTypeId = -88 };
var testPropertyType2 = new PropertyTypeDetail { Alias = "bodyText", Name = "Body Text", SortOrder = 2, DataTypeId = -87 };
var testTemplate1 = new TemplateDetail { Id = 200, Alias = "template1", Name = "Template 1" };
var testTemplate2 = new TemplateDetail { Id = 201, Alias = "template2", Name = "Template 2" };
var testAllowedContentType1 = new AllowedContentTypeDetail { Id = 300, Alias = "subType1", SortOrder = 1 };
var testAllowedContentType2 = new AllowedContentTypeDetail { Id = 301, Alias = "subType2", SortOrder = 2 };
var builder = new ContentTypeBuilder();
// Act
var contentType = builder
.WithId(testId)
.WithKey(testKey)
.WithAlias(testAlias)
.WithName(testName)
.WithCreatorId(testCreatorId)
.WithCreateDate(testCreateDate)
.WithUpdateDate(testUpdateDate)
.WithParentId(testParentId)
.WithLevel(testLevel)
.WithPath(testPath)
.WithSortOrder(testSortOrder)
.WithDescription(testDescription)
.WithIcon(testIcon)
.WithThumbnail(testThumbnail)
.WithTrashed(testTrashed)
.WithPropertyTypeIdsIncrementingFrom(200)
.AddPropertyGroup()
.WithName(testPropertyGroupName)
.WithSortOrder(1)
.AddPropertyType()
.WithAlias(testPropertyType1.Alias)
.WithName(testPropertyType1.Name)
.WithSortOrder(testPropertyType1.SortOrder)
.WithDataTypeId(testPropertyType1.DataTypeId)
.Done()
.AddPropertyType()
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias(testPropertyType2.Alias)
.WithName(testPropertyType2.Name)
.WithSortOrder(testPropertyType2.SortOrder)
.WithDataTypeId(testPropertyType2.DataTypeId)
.Done()
.Done()
.AddAllowedTemplate()
.WithId(testTemplate1.Id)
.WithAlias(testTemplate1.Alias)
.WithName(testTemplate1.Name)
.Done()
.AddAllowedTemplate()
.WithId(testTemplate2.Id)
.WithAlias(testTemplate2.Alias)
.WithName(testTemplate2.Name)
.Done()
.WithDefaultTemplateId(testTemplate1.Id)
.AddAllowedContentType()
.WithId(testAllowedContentType1.Id)
.WithAlias(testAllowedContentType1.Alias)
.WithSortOrder(testAllowedContentType1.SortOrder)
.Done()
.AddAllowedContentType()
.WithId(testAllowedContentType2.Id)
.WithAlias(testAllowedContentType2.Alias)
.WithSortOrder(testAllowedContentType2.SortOrder)
.Done()
.Build();
// Assert
Assert.AreEqual(testId, contentType.Id);
Assert.AreEqual(testAlias, contentType.Alias);
Assert.AreEqual(testName, contentType.Name);
Assert.AreEqual(testKey, contentType.Key);
Assert.AreEqual(testCreateDate, contentType.CreateDate);
Assert.AreEqual(testUpdateDate, contentType.UpdateDate);
Assert.AreEqual(testCreatorId, contentType.CreatorId);
Assert.AreEqual(testParentId, contentType.ParentId);
Assert.AreEqual(testLevel, contentType.Level);
Assert.AreEqual(testPath, contentType.Path);
Assert.AreEqual(testSortOrder, contentType.SortOrder);
Assert.AreEqual(testDescription, contentType.Description);
Assert.AreEqual(testIcon, contentType.Icon);
Assert.AreEqual(testThumbnail, contentType.Thumbnail);
Assert.AreEqual(testTrashed, contentType.Trashed);
Assert.IsFalse(contentType.IsContainer);
Assert.AreEqual(2, contentType.PropertyTypes.Count());
var propertyTypeIds = contentType.PropertyTypes.Select(x => x.Id).OrderBy(x => x);
Assert.AreEqual(testPropertyTypeIdsIncrementingFrom + 1, propertyTypeIds.Min());
Assert.AreEqual(testPropertyTypeIdsIncrementingFrom + 2, propertyTypeIds.Max());
var allowedTemplates = contentType.AllowedTemplates.ToList();
Assert.AreEqual(2, allowedTemplates.Count);
Assert.AreEqual(testTemplate1.Id, allowedTemplates[0].Id);
Assert.AreEqual(testTemplate1.Alias, allowedTemplates[0].Alias);
Assert.AreEqual(testTemplate1.Name, allowedTemplates[0].Name);
Assert.AreEqual(testTemplate1.Id, contentType.DefaultTemplate.Id);
var allowedContentTypes = contentType.AllowedContentTypes.ToList();
Assert.AreEqual(2, allowedContentTypes.Count);
Assert.AreEqual(testAllowedContentType1.Id, allowedContentTypes[0].Id.Value);
Assert.AreEqual(testAllowedContentType1.Alias, allowedContentTypes[0].Alias);
Assert.AreEqual(testAllowedContentType1.SortOrder, allowedContentTypes[0].SortOrder);
}
}
}
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
[TestFixture]
public class DocumentEntitySlimBuilderTests
{
[Test]
public void Is_Built_Correctly()
{
// Arrange
const int testId = 11;
const string testName = "Test";
const int testCreatorId = 22;
const int testLevel = 3;
const string testPath = "-1,23";
const int testParentId = 5;
const int testSortOrder = 6;
const bool testHasChildren = true;
const bool testPublished = true;
const string testContentTypeAlias = "test1";
const string testContentTypeIcon = "icon";
const string testContentTypeThumbnail = "thumb";
var testKey = Guid.NewGuid();
var testCreateDate = DateTime.Now.AddHours(-1);
var testUpdateDate = DateTime.Now;
var testAdditionalData1 = new KeyValuePair<string, object>("test1", 123);
var testAdditionalData2 = new KeyValuePair<string, object>("test2", "hello");
var builder = new DocumentEntitySlimBuilder();
// Act
var item = builder
.WithId(testId)
.WithKey(testKey)
.WithCreatorId(testCreatorId)
.WithCreateDate(testCreateDate)
.WithUpdateDate(testUpdateDate)
.WithName(testName)
.WithParentId(testParentId)
.WithSortOrder(testSortOrder)
.WithLevel(testLevel)
.WithPath(testPath)
.WithContentTypeAlias(testContentTypeAlias)
.WithContentTypeIcon(testContentTypeIcon)
.WithContentTypeThumbnail(testContentTypeThumbnail)
.WithHasChildren(testHasChildren)
.WithPublished(testPublished)
.AddAdditionalData()
.WithKeyValue(testAdditionalData1.Key, testAdditionalData1.Value)
.WithKeyValue(testAdditionalData2.Key, testAdditionalData2.Value)
.Done()
.Build();
// Assert
Assert.AreEqual(testId, item.Id);
Assert.AreEqual(testKey, item.Key);
Assert.AreEqual(testName, item.Name);
Assert.AreEqual(testCreateDate, item.CreateDate);
Assert.AreEqual(testUpdateDate, item.UpdateDate);
Assert.AreEqual(testCreatorId, item.CreatorId);
Assert.AreEqual(testParentId, item.ParentId);
Assert.AreEqual(testSortOrder, item.SortOrder);
Assert.AreEqual(testPath, item.Path);
Assert.AreEqual(testLevel, item.Level);
Assert.AreEqual(testContentTypeAlias, item.ContentTypeAlias);
Assert.AreEqual(testContentTypeIcon, item.ContentTypeIcon);
Assert.AreEqual(testContentTypeThumbnail, item.ContentTypeThumbnail);
Assert.AreEqual(testHasChildren, item.HasChildren);
Assert.AreEqual(testPublished, item.Published);
Assert.AreEqual(2, item.AdditionalData.Count);
Assert.AreEqual(testAdditionalData1.Value, item.AdditionalData[testAdditionalData1.Key]);
Assert.AreEqual(testAdditionalData2.Value, item.AdditionalData[testAdditionalData2.Key]);
}
}
}
@@ -0,0 +1,26 @@
using NUnit.Framework;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
[TestFixture]
public class LanguageBuilderTests
{
[Test]
public void Is_Built_Correctly()
{
// Arrange
var builder = new LanguageBuilder();
// Act
var language = builder
.WithCultureInfo("en-GB")
.Build();
// Assert
Assert.AreEqual("GB", language.IsoCode);
Assert.AreEqual("en", language.CultureName);
}
}
}
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
[TestFixture]
public class MediaTypeBuilderTests
{
[Test]
public void Is_Built_Correctly()
{
// Arrange
const int testId = 99;
var testKey = Guid.NewGuid();
const string testAlias = "mediaType";
const string testName = "Media Type";
const string testPropertyGroupName = "Additional Content";
const int testParentId = 98;
const int testCreatorId = 22;
var testCreateDate = DateTime.Now.AddHours(-1);
var testUpdateDate = DateTime.Now;
const int testLevel = 3;
const string testPath = "-1, 4, 10";
const int testSortOrder = 5;
const string testDescription = "The description";
const string testIcon = "icon";
const string testThumbnail = "thumnail";
const bool testTrashed = true;
const int testPropertyTypeIdsIncrementingFrom = 200;
var testPropertyType1 = new PropertyTypeDetail { Alias = "title", Name = "Title", SortOrder = 1, DataTypeId = -88 };
var testPropertyType2 = new PropertyTypeDetail { Alias = "bodyText", Name = "Body Text", SortOrder = 2, DataTypeId = -87 };
var builder = new MediaTypeBuilder();
// Act
var mediaType = builder
.WithId(testId)
.WithKey(testKey)
.WithAlias(testAlias)
.WithName(testName)
.WithCreatorId(testCreatorId)
.WithCreateDate(testCreateDate)
.WithUpdateDate(testUpdateDate)
.WithParentId(testParentId)
.WithLevel(testLevel)
.WithPath(testPath)
.WithSortOrder(testSortOrder)
.WithDescription(testDescription)
.WithIcon(testIcon)
.WithThumbnail(testThumbnail)
.WithTrashed(testTrashed)
.WithPropertyTypeIdsIncrementingFrom(200)
.WithMediaPropertyGroup()
.AddPropertyGroup()
.WithId(1)
.WithName(testPropertyGroupName)
.WithSortOrder(1)
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias(testPropertyType1.Alias)
.WithName(testPropertyType1.Name)
.WithSortOrder(testPropertyType1.SortOrder)
.WithDataTypeId(testPropertyType1.DataTypeId)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias(testPropertyType2.Alias)
.WithName(testPropertyType2.Name)
.WithSortOrder(testPropertyType2.SortOrder)
.WithDataTypeId(testPropertyType2.DataTypeId)
.Done()
.Done()
.Build();
// Assert
Assert.AreEqual(testId, mediaType.Id);
Assert.AreEqual(testAlias, mediaType.Alias);
Assert.AreEqual(testName, mediaType.Name);
Assert.AreEqual(testKey, mediaType.Key);
Assert.AreEqual(testCreateDate, mediaType.CreateDate);
Assert.AreEqual(testUpdateDate, mediaType.UpdateDate);
Assert.AreEqual(testCreatorId, mediaType.CreatorId);
Assert.AreEqual(testParentId, mediaType.ParentId);
Assert.AreEqual(testLevel, mediaType.Level);
Assert.AreEqual(testPath, mediaType.Path);
Assert.AreEqual(testSortOrder, mediaType.SortOrder);
Assert.AreEqual(testDescription, mediaType.Description);
Assert.AreEqual(testIcon, mediaType.Icon);
Assert.AreEqual(testThumbnail, mediaType.Thumbnail);
Assert.AreEqual(testTrashed, mediaType.Trashed);
Assert.IsFalse(mediaType.IsContainer);
Assert.AreEqual(7, mediaType.PropertyTypes.Count()); // 5 from media properties group, 2 custom
var propertyTypeIds = mediaType.PropertyTypes.Select(x => x.Id).OrderBy(x => x);
Assert.AreEqual(testPropertyTypeIdsIncrementingFrom + 1, propertyTypeIds.Min());
Assert.AreEqual(testPropertyTypeIdsIncrementingFrom + 7, propertyTypeIds.Max());
}
}
}
@@ -12,19 +12,6 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
[TestFixture]
public class MemberBuilderTests
{
private class PropertyTypeDetail
{
public string Alias { get; set; }
public string Name { get; set; }
public string Description { get; set; } = string.Empty;
public int SortOrder { get; set; }
public int DataTypeId { get; set; }
}
[Test]
public void Is_Built_Correctly()
{
@@ -61,6 +48,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
var testPropertyData3 = new KeyValuePair<string, object>("author", "John Doe");
var testAdditionalData1 = new KeyValuePair<string, object>("test1", 123);
var testAdditionalData2 = new KeyValuePair<string, object>("test2", "hello");
const int testPropertyIdsIncrementingFrom = 200;
var builder = new MemberBuilder();
@@ -76,15 +64,12 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
.WithName(testMemberTypePropertyGroupName)
.WithSortOrder(1)
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias(testPropertyType1.Alias)
.WithName(testPropertyType1.Name)
.WithSortOrder(testPropertyType1.SortOrder)
.WithDataTypeId(testPropertyType1.DataTypeId)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias(testPropertyType2.Alias)
.WithName(testPropertyType2.Name)
@@ -92,8 +77,6 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
.WithDataTypeId(testPropertyType2.DataTypeId)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Nvarchar)
.WithAlias(testPropertyType3.Alias)
.WithName(testPropertyType3.Name)
.WithDescription(testPropertyType3.Description)
@@ -156,6 +139,11 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
Assert.AreEqual(testPropertyData1.Value, member.GetValue<string>(testPropertyData1.Key));
Assert.AreEqual(testPropertyData2.Value, member.GetValue<string>(testPropertyData2.Key));
Assert.AreEqual(testPropertyData3.Value, member.GetValue<string>(testPropertyData3.Key));
var propertyIds = member.Properties.Select(x => x.Id).OrderBy(x => x);
Assert.AreEqual(testPropertyIdsIncrementingFrom + 1, propertyIds.Min());
Assert.AreEqual(testPropertyIdsIncrementingFrom + 10, propertyIds.Max());
Assert.AreEqual(2, member.AdditionalData.Count);
Assert.AreEqual(testAdditionalData1.Value, member.AdditionalData[testAdditionalData1.Key]);
Assert.AreEqual(testAdditionalData2.Value, member.AdditionalData[testAdditionalData2.Key]);
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
[TestFixture]
public class MemberTypeBuilderTests
{
[Test]
public void Is_Built_Correctly()
{
// Arrange
const int testId = 99;
var testKey = Guid.NewGuid();
const string testAlias = "memberType";
const string testName = "Member Type";
const string testPropertyGroupName = "Content";
const int testParentId = 98;
const int testCreatorId = 22;
var testCreateDate = DateTime.Now.AddHours(-1);
var testUpdateDate = DateTime.Now;
const int testLevel = 3;
const string testPath = "-1, 4, 10";
const int testSortOrder = 5;
const string testDescription = "The description";
const string testIcon = "icon";
const string testThumbnail = "thumnail";
const bool testTrashed = true;
const int testPropertyTypeIdsIncrementingFrom = 200;
var testPropertyType1 = new PropertyTypeDetail { Alias = "title", Name = "Title", SortOrder = 1, DataTypeId = -88 };
var testPropertyType2 = new PropertyTypeDetail { Alias = "bodyText", Name = "Body Text", SortOrder = 2, DataTypeId = -87 };
var testPropertyData1 = new KeyValuePair<string, object>("title", "Name member");
var builder = new MemberTypeBuilder();
// Act
var memberType = builder
.WithId(testId)
.WithKey(testKey)
.WithAlias(testAlias)
.WithName(testName)
.WithCreatorId(testCreatorId)
.WithCreateDate(testCreateDate)
.WithUpdateDate(testUpdateDate)
.WithParentId(testParentId)
.WithLevel(testLevel)
.WithPath(testPath)
.WithSortOrder(testSortOrder)
.WithDescription(testDescription)
.WithIcon(testIcon)
.WithThumbnail(testThumbnail)
.WithTrashed(testTrashed)
.WithPropertyTypeIdsIncrementingFrom(200)
.WithMembershipPropertyGroup()
.AddPropertyGroup()
.WithId(1)
.WithName(testPropertyGroupName)
.WithSortOrder(1)
.AddPropertyType()
.WithAlias(testPropertyType1.Alias)
.WithName(testPropertyType1.Name)
.WithSortOrder(testPropertyType1.SortOrder)
.Done()
.AddPropertyType()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TextBox)
.WithValueStorageType(ValueStorageType.Ntext)
.WithAlias(testPropertyType2.Alias)
.WithName(testPropertyType2.Name)
.WithSortOrder(testPropertyType2.SortOrder)
.WithDataTypeId(testPropertyType2.DataTypeId)
.Done()
.Done()
.WithMemberCanEditProperty(testPropertyType1.Alias, true)
.WithMemberCanViewProperty(testPropertyType2.Alias, true)
.Build();
// Assert
Assert.AreEqual(testId, memberType.Id);
Assert.AreEqual(testAlias, memberType.Alias);
Assert.AreEqual(testName, memberType.Name);
Assert.AreEqual(testKey, memberType.Key);
Assert.AreEqual(testCreateDate, memberType.CreateDate);
Assert.AreEqual(testUpdateDate, memberType.UpdateDate);
Assert.AreEqual(testCreatorId, memberType.CreatorId);
Assert.AreEqual(testParentId, memberType.ParentId);
Assert.AreEqual(testLevel, memberType.Level);
Assert.AreEqual(testPath, memberType.Path);
Assert.AreEqual(testSortOrder, memberType.SortOrder);
Assert.AreEqual(testDescription, memberType.Description);
Assert.AreEqual(testIcon, memberType.Icon);
Assert.AreEqual(testThumbnail, memberType.Thumbnail);
Assert.AreEqual(testTrashed, memberType.Trashed);
Assert.IsFalse(memberType.IsContainer);
Assert.AreEqual(9, memberType.PropertyTypes.Count()); // 7 from membership properties group, 2 custom
var propertyTypeIds = memberType.PropertyTypes.Select(x => x.Id).OrderBy(x => x);
Assert.AreEqual(testPropertyTypeIdsIncrementingFrom + 1, propertyTypeIds.Min());
Assert.AreEqual(testPropertyTypeIdsIncrementingFrom + 9, propertyTypeIds.Max());
Assert.IsTrue(memberType.MemberCanEditProperty(testPropertyType1.Alias));
Assert.IsFalse(memberType.MemberCanViewProperty(testPropertyType1.Alias));
Assert.IsTrue(memberType.MemberCanViewProperty(testPropertyType2.Alias));
Assert.IsFalse(memberType.MemberCanEditProperty(testPropertyType2.Alias));
}
}
}
@@ -0,0 +1,15 @@
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
public class PropertyTypeDetail
{
public string Alias { get; set; }
public string Name { get; set; }
public string Description { get; set; } = string.Empty;
public int SortOrder { get; set; }
public int DataTypeId { get; set; }
}
}
@@ -10,20 +10,20 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
public void Is_Built_Correctly()
{
// Arrange
const string path = "/css/styles.css";
const string content = @"body { color:#000; } .bold {font-weight:bold;}";
const string testPath = "/css/styles.css";
const string testContent = @"body { color:#000; } .bold {font-weight:bold;}";
var builder = new StylesheetBuilder();
// Act
var stylesheet = builder
.WithPath(path)
.WithContent(content)
.WithPath(testPath)
.WithContent(testContent)
.Build();
// Assert
Assert.AreEqual("\\css\\styles.css", stylesheet.Path);
Assert.AreEqual(content, stylesheet.Content);
Assert.AreEqual(testContent, stylesheet.Content);
}
}
}
@@ -1,5 +1,6 @@
using System;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
@@ -12,44 +13,44 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
public void Is_Built_Correctly()
{
// Arrange
const int id = 3;
const string alias = "test";
const string name = "Test";
var key = Guid.NewGuid();
var createDate = DateTime.Now.AddHours(-1);
var updateDate = DateTime.Now;
const string path = "-1,3";
const string content = "blah";
const string masterTemplateAlias = "master";
const int masterTemplateId = 88;
const int testId = 3;
const string testAlias = "test";
const string testName = "Test";
var testKey = Guid.NewGuid();
var testCreateDate = DateTime.Now.AddHours(-1);
var testUpdateDate = DateTime.Now;
const string testPath = "-1,3";
const string testContent = "blah";
const string testMasterTemplateAlias = "master";
const int testMasterTemplateId = 88;
var builder = new TemplateBuilder();
// Act
var template = builder
.WithId(3)
.WithAlias(alias)
.WithName(name)
.WithCreateDate(createDate)
.WithUpdateDate(updateDate)
.WithKey(key)
.WithPath(path)
.WithContent(content)
.AsMasterTemplate(masterTemplateAlias, masterTemplateId)
.WithAlias(testAlias)
.WithName(testName)
.WithCreateDate(testCreateDate)
.WithUpdateDate(testUpdateDate)
.WithKey(testKey)
.WithPath(testPath)
.WithContent(testContent)
.AsMasterTemplate(testMasterTemplateAlias, testMasterTemplateId)
.Build();
// Assert
Assert.AreEqual(id, template.Id);
Assert.AreEqual(alias, template.Alias);
Assert.AreEqual(name, template.Name);
Assert.AreEqual(createDate, template.CreateDate);
Assert.AreEqual(updateDate, template.UpdateDate);
Assert.AreEqual(key, template.Key);
Assert.AreEqual(path, template.Path);
Assert.AreEqual(content, template.Content);
Assert.AreEqual(testId, template.Id);
Assert.AreEqual(testAlias, template.Alias);
Assert.AreEqual(testName, template.Name);
Assert.AreEqual(testCreateDate, template.CreateDate);
Assert.AreEqual(testUpdateDate, template.UpdateDate);
Assert.AreEqual(testKey, template.Key);
Assert.AreEqual(testPath, template.Path);
Assert.AreEqual(testContent, template.Content);
Assert.IsTrue(template.IsMasterTemplate);
Assert.AreEqual(masterTemplateAlias, template.MasterTemplateAlias);
Assert.AreEqual(masterTemplateId, template.MasterTemplateId.Value);
Assert.AreEqual(testMasterTemplateAlias, template.MasterTemplateAlias);
Assert.AreEqual(testMasterTemplateId, ((Template)template).MasterTemplateId.Value);
}
}
}
@@ -0,0 +1,11 @@
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
public class TemplateDetail
{
public int Id { get; set; }
public string Alias { get; set; }
public string Name { get; set; }
}
}
@@ -0,0 +1,49 @@
using System;
using NUnit.Framework;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders
{
[TestFixture]
public class UserGroupBuilderTests
{
[Test]
public void Is_Built_Correctly()
{
// Arrange
const int testId = 10;
const string testAlias = "test";
const string testName = "Test";
const int testUserCount = 11;
const string testIcon = "icon";
const string testPermissions = "abc";
const int testStartContentId = 3;
const int testStartMediaId = 8;
var builder = new UserGroupBuilder();
// Act
var userGroup = builder
.WithId(testId)
.WithAlias(testAlias)
.WithName(testName)
.WithUserCount(testUserCount)
.WithIcon(testIcon)
.WithPermissions(testPermissions)
.WithStartContentId(testStartContentId)
.WithStartMediaId(testStartMediaId)
.Build();
// Assert
Assert.AreEqual(testId, userGroup.Id);
Assert.AreEqual(testAlias, userGroup.Alias);
Assert.AreEqual(testName, userGroup.Name);
Assert.AreEqual(testUserCount, userGroup.UserCount);
Assert.AreEqual(testIcon, userGroup.Icon);
Assert.AreEqual(testPermissions, string.Join(string.Empty, userGroup.Permissions));
Assert.AreEqual(testStartContentId, userGroup.StartContentId);
Assert.AreEqual(testStartMediaId, userGroup.StartMediaId);
}
}
}
@@ -1,520 +0,0 @@
using System;
using System.Diagnostics;
using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Serialization;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Tests.Testing;
namespace Umbraco.Tests.Models
{
[TestFixture]
public class ContentTypeTests : UmbracoTestBase
{
[Test]
[Ignore("Ignoring this test until we actually enforce this, see comments in ContentTypeBase.PropertyTypesChanged")]
public void Cannot_Add_Duplicate_Property_Aliases()
{
var contentType = MockedContentTypes.CreateBasicContentType();
contentType.PropertyGroups.Add(new PropertyGroup(new PropertyTypeCollection(false, new[]
{
new PropertyType(TestHelper.ShortStringHelper, "testPropertyEditor", ValueStorageType.Nvarchar){ Alias = "myPropertyType" }
})));
Assert.Throws<InvalidOperationException>(() =>
contentType.PropertyTypeCollection.Add(
new PropertyType(TestHelper.ShortStringHelper, "testPropertyEditor", ValueStorageType.Nvarchar) { Alias = "myPropertyType" }));
}
[Test]
[Ignore("Ignoring this test until we actually enforce this, see comments in ContentTypeBase.PropertyTypesChanged")]
public void Cannot_Update_Duplicate_Property_Aliases()
{
var contentType = MockedContentTypes.CreateBasicContentType();
contentType.PropertyGroups.Add(new PropertyGroup(new PropertyTypeCollection(false, new[]
{
new PropertyType(TestHelper.ShortStringHelper, "testPropertyEditor", ValueStorageType.Nvarchar){ Alias = "myPropertyType" }
})));
contentType.PropertyTypeCollection.Add(new PropertyType(TestHelper.ShortStringHelper, "testPropertyEditor", ValueStorageType.Nvarchar) { Alias = "myPropertyType2" });
var toUpdate = contentType.PropertyTypeCollection["myPropertyType2"];
Assert.Throws<InvalidOperationException>(() => toUpdate.Alias = "myPropertyType");
}
[Test]
public void Can_Deep_Clone_Content_Type_Sort()
{
var contentType = new ContentTypeSort(new Lazy<int>(() => 3), 4, "test");
var clone = (ContentTypeSort)contentType.DeepClone();
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id.Value, contentType.Id.Value);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreEqual(clone.Alias, contentType.Alias);
}
[Test]
public void Can_Deep_Clone_Content_Type_With_Reset_Identities()
{
var contentType = MockedContentTypes.CreateTextPageContentType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
foreach (var group in contentType.PropertyGroups)
{
group.Id = ++i;
}
//add a property type without a property group
contentType.PropertyTypeCollection.Add(
new PropertyType(TestHelper.ShortStringHelper, "test", ValueStorageType.Ntext, "title2") { Name = "Title2", Description = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 });
contentType.AllowedTemplates = new[] { new Template(TestHelper.ShortStringHelper, "Name", "name") { Id = 200 }, new Template(TestHelper.ShortStringHelper, "Name2", "name2") { Id = 201 } };
contentType.AllowedContentTypes = new[] { new ContentTypeSort(new Lazy<int>(() => 888), 8, "sub"), new ContentTypeSort(new Lazy<int>(() => 889), 9, "sub2") };
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.SetDefaultTemplate(new Template(TestHelper.ShortStringHelper, (string)"Test Template", (string)"testTemplate")
{
Id = 88
});
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
//ensure that nothing is marked as dirty
contentType.ResetDirtyProperties(false);
var clone = (ContentType)contentType.DeepCloneWithResetIdentities("newAlias");
Assert.AreEqual("newAlias", clone.Alias);
Assert.AreNotEqual("newAlias", contentType.Alias);
Assert.IsFalse(clone.HasIdentity);
foreach (var propertyGroup in clone.PropertyGroups)
{
Assert.IsFalse(propertyGroup.HasIdentity);
foreach (var propertyType in propertyGroup.PropertyTypes)
{
Assert.IsFalse(propertyType.HasIdentity);
}
}
foreach (var propertyType in clone.PropertyTypes.Where(x => x.HasIdentity))
{
Assert.IsFalse(propertyType.HasIdentity);
}
}
private static IProfilingLogger GetTestProfilingLogger()
{
var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var profiler = new TestProfiler();
return new ProfilingLogger(logger, profiler);
}
[Ignore("fixme - ignored test")]
[Test]
public void Can_Deep_Clone_Content_Type_Perf_Test()
{
// Arrange
var contentType = MockedContentTypes.CreateTextPageContentType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
foreach (var group in contentType.PropertyGroups)
{
group.Id = ++i;
}
contentType.AllowedTemplates = new[] { new Template(TestHelper.ShortStringHelper, (string)"Name", (string)"name") { Id = 200 }, new Template(TestHelper.ShortStringHelper, (string)"Name2", (string)"name2") { Id = 201 } };
contentType.AllowedContentTypes = new[] { new ContentTypeSort(new Lazy<int>(() => 888), 8, "sub"), new ContentTypeSort(new Lazy<int>(() => 889), 9, "sub2") };
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.SetDefaultTemplate(new Template(TestHelper.ShortStringHelper, (string)"Test Template", (string)"testTemplate")
{
Id = 88
});
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
var proflog = GetTestProfilingLogger();
using (proflog.DebugDuration<ContentTypeTests>("STARTING PERF TEST"))
{
for (var j = 0; j < 1000; j++)
{
using (proflog.DebugDuration<ContentTypeTests>("Cloning content type"))
{
var clone = (ContentType)contentType.DeepClone();
}
}
}
}
[Test]
public void Can_Deep_Clone_Content_Type()
{
// Arrange
var contentType = MockedContentTypes.CreateTextPageContentType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
foreach (var group in contentType.PropertyGroups)
{
group.Id = ++i;
}
contentType.AllowedTemplates = new[] { new Template(TestHelper.ShortStringHelper, (string)"Name", (string)"name") { Id = 200 }, new Template(TestHelper.ShortStringHelper, (string)"Name2", (string)"name2") { Id = 201 } };
contentType.AllowedContentTypes = new[] { new ContentTypeSort(new Lazy<int>(() => 888), 8, "sub"), new ContentTypeSort(new Lazy<int>(() => 889), 9, "sub2") };
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.SetDefaultTemplate(new Template(TestHelper.ShortStringHelper, (string)"Test Template", (string)"testTemplate")
{
Id = 88
});
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
// Act
var clone = (ContentType)contentType.DeepClone();
// Assert
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id, contentType.Id);
Assert.AreEqual(clone.AllowedTemplates.Count(), contentType.AllowedTemplates.Count());
for (var index = 0; index < contentType.AllowedTemplates.Count(); index++)
{
Assert.AreNotSame(clone.AllowedTemplates.ElementAt(index), contentType.AllowedTemplates.ElementAt(index));
Assert.AreEqual(clone.AllowedTemplates.ElementAt(index), contentType.AllowedTemplates.ElementAt(index));
}
Assert.AreNotSame(clone.PropertyGroups, contentType.PropertyGroups);
Assert.AreEqual(clone.PropertyGroups.Count, contentType.PropertyGroups.Count);
for (var index = 0; index < contentType.PropertyGroups.Count; index++)
{
Assert.AreNotSame(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
Assert.AreEqual(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
}
Assert.AreNotSame(clone.PropertyTypes, contentType.PropertyTypes);
Assert.AreEqual(clone.PropertyTypes.Count(), contentType.PropertyTypes.Count());
Assert.AreEqual(0, clone.NoGroupPropertyTypes.Count());
for (var index = 0; index < contentType.PropertyTypes.Count(); index++)
{
Assert.AreNotSame(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
Assert.AreEqual(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
}
Assert.AreEqual(clone.CreateDate, contentType.CreateDate);
Assert.AreEqual(clone.CreatorId, contentType.CreatorId);
Assert.AreEqual(clone.Key, contentType.Key);
Assert.AreEqual(clone.Level, contentType.Level);
Assert.AreEqual(clone.Path, contentType.Path);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreNotSame(clone.DefaultTemplate, contentType.DefaultTemplate);
Assert.AreEqual(clone.DefaultTemplate, contentType.DefaultTemplate);
Assert.AreEqual(clone.DefaultTemplateId, contentType.DefaultTemplateId);
Assert.AreEqual(clone.Trashed, contentType.Trashed);
Assert.AreEqual(clone.UpdateDate, contentType.UpdateDate);
Assert.AreEqual(clone.Thumbnail, contentType.Thumbnail);
Assert.AreEqual(clone.Icon, contentType.Icon);
Assert.AreEqual(clone.IsContainer, contentType.IsContainer);
//This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
{
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(contentType, null));
}
//need to ensure the event handlers are wired
var asDirty = (ICanBeDirty)clone;
Assert.IsFalse(asDirty.IsPropertyDirty("PropertyTypes"));
clone.AddPropertyType(new PropertyType(TestHelper.ShortStringHelper, "test", ValueStorageType.Nvarchar, "blah"));
Assert.IsTrue(asDirty.IsPropertyDirty("PropertyTypes"));
Assert.IsFalse(asDirty.IsPropertyDirty("PropertyGroups"));
clone.AddPropertyGroup("hello");
Assert.IsTrue(asDirty.IsPropertyDirty("PropertyGroups"));
}
[Test]
public void Can_Serialize_Content_Type_Without_Error()
{
// Arrange
var contentType = MockedContentTypes.CreateTextPageContentType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
contentType.AllowedTemplates = new[] { new Template(TestHelper.ShortStringHelper, (string)"Name", (string)"name") { Id = 200 }, new Template(TestHelper.ShortStringHelper, (string)"Name2", (string)"name2") { Id = 201 } };
contentType.AllowedContentTypes = new[] { new ContentTypeSort(new Lazy<int>(() => 888), 8, "sub"), new ContentTypeSort(new Lazy<int>(() => 889), 9, "sub2") };
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.SetDefaultTemplate(new Template(TestHelper.ShortStringHelper, (string)"Test Template", (string)"testTemplate")
{
Id = 88
});
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
var json = JsonConvert.SerializeObject(contentType);
Debug.Print(json);
}
[Test]
public void Can_Deep_Clone_Media_Type()
{
// Arrange
var contentType = MockedContentTypes.CreateImageMediaType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
// Act
var clone = (MediaType)contentType.DeepClone();
// Assert
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id, contentType.Id);
Assert.AreEqual(clone.PropertyGroups.Count, contentType.PropertyGroups.Count);
for (var index = 0; index < contentType.PropertyGroups.Count; index++)
{
Assert.AreNotSame(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
Assert.AreEqual(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
}
Assert.AreEqual(clone.PropertyTypes.Count(), contentType.PropertyTypes.Count());
for (var index = 0; index < contentType.PropertyTypes.Count(); index++)
{
Assert.AreNotSame(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
Assert.AreEqual(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
}
Assert.AreEqual(clone.CreateDate, contentType.CreateDate);
Assert.AreEqual(clone.CreatorId, contentType.CreatorId);
Assert.AreEqual(clone.Key, contentType.Key);
Assert.AreEqual(clone.Level, contentType.Level);
Assert.AreEqual(clone.Path, contentType.Path);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreEqual(clone.Trashed, contentType.Trashed);
Assert.AreEqual(clone.UpdateDate, contentType.UpdateDate);
Assert.AreEqual(clone.Thumbnail, contentType.Thumbnail);
Assert.AreEqual(clone.Icon, contentType.Icon);
Assert.AreEqual(clone.IsContainer, contentType.IsContainer);
//This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
{
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(contentType, null));
}
}
[Test]
public void Can_Serialize_Media_Type_Without_Error()
{
// Arrange
var contentType = MockedContentTypes.CreateImageMediaType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
var json = JsonConvert.SerializeObject(contentType);
Debug.Print(json);
}
[Test]
public void Can_Deep_Clone_Member_Type()
{
// Arrange
var contentType = MockedContentTypes.CreateSimpleMemberType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
contentType.SetMemberCanEditProperty("title", true);
contentType.SetMemberCanViewProperty("bodyText", true);
// Act
var clone = (MemberType)contentType.DeepClone();
// Assert
Assert.AreNotSame(clone, contentType);
Assert.AreEqual(clone, contentType);
Assert.AreEqual(clone.Id, contentType.Id);
Assert.AreEqual(clone.PropertyGroups.Count, contentType.PropertyGroups.Count);
for (var index = 0; index < contentType.PropertyGroups.Count; index++)
{
Assert.AreNotSame(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
Assert.AreEqual(clone.PropertyGroups[index], contentType.PropertyGroups[index]);
}
Assert.AreEqual(clone.PropertyTypes.Count(), contentType.PropertyTypes.Count());
for (var index = 0; index < contentType.PropertyTypes.Count(); index++)
{
Assert.AreNotSame(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
Assert.AreEqual(clone.PropertyTypes.ElementAt(index), contentType.PropertyTypes.ElementAt(index));
}
Assert.AreEqual(clone.CreateDate, contentType.CreateDate);
Assert.AreEqual(clone.CreatorId, contentType.CreatorId);
Assert.AreEqual(clone.Key, contentType.Key);
Assert.AreEqual(clone.Level, contentType.Level);
Assert.AreEqual(clone.Path, contentType.Path);
Assert.AreEqual(clone.SortOrder, contentType.SortOrder);
Assert.AreEqual(clone.Trashed, contentType.Trashed);
Assert.AreEqual(clone.UpdateDate, contentType.UpdateDate);
Assert.AreEqual(clone.Thumbnail, contentType.Thumbnail);
Assert.AreEqual(clone.Icon, contentType.Icon);
Assert.AreEqual(clone.IsContainer, contentType.IsContainer);
Assert.AreEqual(clone.MemberTypePropertyTypes, contentType.MemberTypePropertyTypes);
//This double verifies by reflection
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
{
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(contentType, null));
}
}
[Test]
public void Can_Serialize_Member_Type_Without_Error()
{
// Arrange
var contentType = MockedContentTypes.CreateSimpleMemberType();
contentType.Id = 99;
var i = 200;
foreach (var propertyType in contentType.PropertyTypes)
{
propertyType.Id = ++i;
}
contentType.Id = 10;
contentType.CreateDate = DateTime.Now;
contentType.CreatorId = 22;
contentType.Description = "test";
contentType.Icon = "icon";
contentType.IsContainer = true;
contentType.Thumbnail = "thumb";
contentType.Key = Guid.NewGuid();
contentType.Level = 3;
contentType.Path = "-1,4,10";
contentType.SortOrder = 5;
contentType.Trashed = false;
contentType.UpdateDate = DateTime.Now;
contentType.SetMemberCanEditProperty("title", true);
contentType.SetMemberCanViewProperty("bodyText", true);
var json = JsonConvert.SerializeObject(contentType);
Debug.Print(json);
}
}
}
@@ -1,44 +0,0 @@
using System;
using System.Diagnostics;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Serialization;
namespace Umbraco.Tests.Models
{
[TestFixture]
public class LightEntityTest
{
[Test]
public void Can_Serialize_Without_Error()
{
var item = new DocumentEntitySlim()
{
Id = 3,
ContentTypeAlias = "test1",
CreatorId = 4,
Key = Guid.NewGuid(),
UpdateDate = DateTime.Now,
CreateDate = DateTime.Now,
Name = "Test",
ParentId = 5,
SortOrder = 6,
Path = "-1,23",
Level = 7,
ContentTypeIcon = "icon",
ContentTypeThumbnail = "thumb",
HasChildren = true,
Edited = true,
Published = true,
NodeObjectType = Guid.NewGuid()
};
item.AdditionalData.Add("test1", 3);
item.AdditionalData.Add("test2", "valuie");
var json = JsonConvert.SerializeObject(item);
Debug.Print(json); // FIXME: compare with v7
}
}
}
+2 -9
View File
@@ -132,16 +132,15 @@
<Compile Include="LegacyXmlPublishedCache\PreviewXmlDto.cs" />
<Compile Include="Logging\LogviewerTests.cs" />
<Compile Include="Manifest\ManifestContentAppTests.cs" />
<Compile Include="Mapping\MappingTests.cs" />
<Compile Include="Migrations\MigrationPlanTests.cs" />
<Compile Include="Migrations\MigrationTests.cs" />
<Compile Include="ModelsBuilder\BuilderTests.cs" />
<Compile Include="ModelsBuilder\ConfigTests.cs" />
<Compile Include="ModelsBuilder\StringExtensions.cs" />
<Compile Include="ModelsBuilder\UmbracoApplicationTests.cs" />
<Compile Include="Models\ContentScheduleTests.cs" />
<Compile Include="Models\CultureImpactTests.cs" />
<Compile Include="Models\ContentXmlTest.cs" />
<Compile Include="Models\ImageProcessorImageUrlGeneratorTest.cs" />
<Compile Include="Models\Mapping\UserModelMapperTests.cs" />
<Compile Include="Models\VariationTests.cs" />
<Compile Include="Persistence\Mappers\MapperTestBase.cs" />
<Compile Include="Persistence\Repositories\DocumentRepositoryTest.cs" />
@@ -190,7 +189,6 @@
<Compile Include="Issues\U9560.cs" />
<Compile Include="Integration\ContentEventsTests.cs" />
<Compile Include="Migrations\AdvancedMigrationTests.cs" />
<Compile Include="Models\Mapping\UserModelMapperTests.cs" />
<Compile Include="Packaging\PackageExtractionTests.cs" />
<Compile Include="Persistence\NPocoTests\NPocoFetchTests.cs" />
<Compile Include="Persistence\NPocoTests\NPocoSqlTemplateTests.cs" />
@@ -296,10 +294,6 @@
<Compile Include="Models\Collections\Item.cs" />
<Compile Include="Models\Collections\OrderItem.cs" />
<Compile Include="Models\Collections\SimpleOrder.cs" />
<Compile Include="Models\ContentTypeTests.cs" />
<Compile Include="Models\DeepCloneHelperTests.cs" />
<Compile Include="Models\DictionaryTranslationTests.cs" />
<Compile Include="Models\LightEntityTest.cs" />
<Compile Include="Web\Mvc\RenderModelBinderTests.cs" />
<Compile Include="Web\Mvc\SurfaceControllerTests.cs" />
<Compile Include="Web\Mvc\UmbracoViewPageTests.cs" />
@@ -386,7 +380,6 @@
<Compile Include="IO\IoHelperTests.cs" />
<Compile Include="PropertyEditors\PropertyEditorValueConverterTests.cs" />
<Compile Include="Models\ContentTests.cs" />
<Compile Include="Models\ContentXmlTest.cs" />
<Compile Include="Persistence\SqlCeTableByTableTest.cs" />
<Compile Include="Persistence\DatabaseContextTests.cs" />
<Compile Include="Persistence\Mappers\ContentMapperTest.cs" />