public void IContentType_To_ContentTypeDisplay()
    {
        // Arrange
        //// _dataTypeService.Setup(x => x.GetDataType(It.IsAny<int>()))
        ////     .Returns(new DataType(new VoidEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(),Mock.Of<ILocalizedTextService>(), Mock.Of<IShortStringHelper>())));
        //
        // setup the mocks to return the data we want to test against...
        var contentType = ContentTypeBuilder.CreateTextPageContentType();

        ContentTypeBuilder.EnsureAllIds(contentType, 8888);

        // Act
        var result = _sut.Map <DocumentTypeDisplay>(contentType);

        // Assert
        Assert.AreEqual(contentType.Alias, result.Alias);
        Assert.AreEqual(contentType.Description, result.Description);
        Assert.AreEqual(contentType.Icon, result.Icon);
        Assert.AreEqual(contentType.Id, result.Id);
        Assert.AreEqual(contentType.Name, result.Name);
        Assert.AreEqual(contentType.ParentId, result.ParentId);
        Assert.AreEqual(contentType.Path, result.Path);
        Assert.AreEqual(contentType.Thumbnail, result.Thumbnail);
        Assert.AreEqual(contentType.IsContainer, result.IsContainer);
        Assert.AreEqual(contentType.CreateDate, result.CreateDate);
        Assert.AreEqual(contentType.UpdateDate, result.UpdateDate);
        Assert.AreEqual(contentType.DefaultTemplate.Alias, result.DefaultTemplate.Alias);

        Assert.AreEqual(contentType.PropertyGroups.Count, result.Groups.Count());
        for (var i = 0; i < contentType.PropertyGroups.Count; i++)
        {
            Assert.AreEqual(contentType.PropertyGroups[i].Id, result.Groups.ElementAt(i).Id);
            Assert.AreEqual(contentType.PropertyGroups[i].Name, result.Groups.ElementAt(i).Name);
            var propTypes = contentType.PropertyGroups[i].PropertyTypes;

            Assert.AreEqual(propTypes.Count, result.Groups.ElementAt(i).Properties.Count());
            for (var j = 0; j < propTypes.Count; j++)
            {
                Assert.AreEqual(propTypes[j].Id, result.Groups.ElementAt(i).Properties.ElementAt(j).Id);
                Assert.AreEqual(propTypes[j].DataTypeId, result.Groups.ElementAt(i).Properties.ElementAt(j).DataTypeId);
                Assert.AreEqual(propTypes[j].LabelOnTop, result.Groups.ElementAt(i).Properties.ElementAt(j).LabelOnTop);
            }
        }

        Assert.AreEqual(contentType.AllowedTemplates.Count(), result.AllowedTemplates.Count());
        for (var i = 0; i < contentType.AllowedTemplates.Count(); i++)
        {
            Assert.AreEqual(contentType.AllowedTemplates.ElementAt(i).Id, result.AllowedTemplates.ElementAt(i).Id);
        }

        Assert.AreEqual(contentType.AllowedContentTypes.Count(), result.AllowedContentTypes.Count());
        for (var i = 0; i < contentType.AllowedContentTypes.Count(); i++)
        {
            Assert.AreEqual(contentType.AllowedContentTypes.ElementAt(i).Id.Value, result.AllowedContentTypes.ElementAt(i));
        }
    }
    public void IContentTypeComposition_To_ContentTypeDisplay()
    {
        // Arrange
        var ctMain = ContentTypeBuilder.CreateSimpleContentType();

        // not assigned to tab
        ctMain.AddPropertyType(
            new PropertyType(ShortStringHelper, Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext)
        {
            Alias       = "umbracoUrlName",
            Name        = "Slug",
            Description = string.Empty,
            Mandatory   = false,
            SortOrder   = 1,
            DataTypeId  = -88
        });
        ContentTypeBuilder.EnsureAllIds(ctMain, 8888);
        var ctChild1 = ContentTypeBuilder.CreateSimpleContentType("child1", "Child 1", ctMain, randomizeAliases: true);

        ctChild1.AddPropertyType(
            new PropertyType(ShortStringHelper, Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext)
        {
            Alias       = "someProperty",
            Name        = "Some Property",
            Description = string.Empty,
            Mandatory   = false,
            SortOrder   = 1,
            DataTypeId  = -88
        },
            "anotherTab",
            "Another tab");
        ContentTypeBuilder.EnsureAllIds(ctChild1, 7777);
        var contentType = ContentTypeBuilder.CreateSimpleContentType("child2", "Child 2", ctChild1, randomizeAliases: true, propertyGroupAlias: "customGroup", propertyGroupName: "CustomGroup");

        // not assigned to tab
        contentType.AddPropertyType(
            new PropertyType(ShortStringHelper, Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext)
        {
            Alias       = "umbracoUrlAlias",
            Name        = "AltUrl",
            Description = string.Empty,
            Mandatory   = false,
            SortOrder   = 1,
            DataTypeId  = -88
        });
        ContentTypeBuilder.EnsureAllIds(contentType, 6666);

        // Act
        var result = _sut.Map <DocumentTypeDisplay>(contentType);

        // Assert
        Assert.AreEqual(contentType.Alias, result.Alias);
        Assert.AreEqual(contentType.Description, result.Description);
        Assert.AreEqual(contentType.Icon, result.Icon);
        Assert.AreEqual(contentType.Id, result.Id);
        Assert.AreEqual(contentType.Name, result.Name);
        Assert.AreEqual(contentType.ParentId, result.ParentId);
        Assert.AreEqual(contentType.Path, result.Path);
        Assert.AreEqual(contentType.Thumbnail, result.Thumbnail);
        Assert.AreEqual(contentType.IsContainer, result.IsContainer);
        Assert.AreEqual(contentType.CreateDate, result.CreateDate);
        Assert.AreEqual(contentType.UpdateDate, result.UpdateDate);
        Assert.AreEqual(contentType.DefaultTemplate.Alias, result.DefaultTemplate.Alias);

        Assert.AreEqual(contentType.CompositionPropertyGroups.Select(x => x.Name).Distinct().Count(), result.Groups.Count(x => x.IsGenericProperties == false));
        Assert.AreEqual(1, result.Groups.Count(x => x.IsGenericProperties));
        Assert.AreEqual(contentType.PropertyGroups.Count(), result.Groups.Count(x => x.Inherited == false && x.IsGenericProperties == false));

        var allPropertiesMapped  = result.Groups.SelectMany(x => x.Properties).ToArray();
        var allPropertyIdsMapped = allPropertiesMapped.Select(x => x.Id).ToArray();
        var allSourcePropertyIds = contentType.CompositionPropertyTypes.Select(x => x.Id).ToArray();

        Assert.AreEqual(contentType.PropertyTypes.Count(), allPropertiesMapped.Count(x => x.Inherited == false));
        Assert.AreEqual(allPropertyIdsMapped.Count(), allSourcePropertyIds.Count());
        Assert.IsTrue(allPropertyIdsMapped.ContainsAll(allSourcePropertyIds));

        Assert.AreEqual(2, result.Groups.Count(x => x.ParentTabContentTypes.Any()));
        Assert.IsTrue(
            result.Groups.SelectMany(x => x.ParentTabContentTypes).ContainsAll(new[] { ctMain.Id, ctChild1.Id }));

        Assert.AreEqual(contentType.AllowedTemplates.Count(), result.AllowedTemplates.Count());
        for (var i = 0; i < contentType.AllowedTemplates.Count(); i++)
        {
            Assert.AreEqual(contentType.AllowedTemplates.ElementAt(i).Id, result.AllowedTemplates.ElementAt(i).Id);
        }

        Assert.AreEqual(contentType.AllowedContentTypes.Count(), result.AllowedContentTypes.Count());
        for (var i = 0; i < contentType.AllowedContentTypes.Count(); i++)
        {
            Assert.AreEqual(contentType.AllowedContentTypes.ElementAt(i).Id.Value, result.AllowedContentTypes.ElementAt(i));
        }
    }