public void MemberPropertyTypeBasic_To_MemberPropertyTypeDisplay()
    {
        var basic = new MemberPropertyTypeBasic
        {
            Id                    = 33,
            SortOrder             = 1,
            Alias                 = "prop1",
            Description           = "property 1",
            DataTypeId            = -88,
            GroupId               = 222,
            Label                 = "Prop 1",
            MemberCanViewProperty = true,
            MemberCanEditProperty = true,
            IsSensitiveData       = true,
            Validation            = new PropertyTypeValidation {
                Mandatory = true, Pattern = "xyz"
            }
        };

        var result = _sut.Map <MemberPropertyTypeDisplay>(basic);

        Assert.AreEqual(basic.Id, result.Id);
        Assert.AreEqual(basic.SortOrder, result.SortOrder);
        Assert.AreEqual(basic.Alias, result.Alias);
        Assert.AreEqual(basic.Description, result.Description);
        Assert.AreEqual(basic.GroupId, result.GroupId);
        Assert.AreEqual(basic.Inherited, result.Inherited);
        Assert.AreEqual(basic.Label, result.Label);
        Assert.AreEqual(basic.Validation, result.Validation);
        Assert.AreEqual(basic.MemberCanViewProperty, result.MemberCanViewProperty);
        Assert.AreEqual(basic.MemberCanEditProperty, result.MemberCanEditProperty);
        Assert.AreEqual(basic.IsSensitiveData, result.IsSensitiveData);
    }
    public void MemberPropertyTypeBasic_To_PropertyType()
    {
        var basic = new MemberPropertyTypeBasic
        {
            Id          = 33,
            SortOrder   = 1,
            Alias       = "prop1",
            Description = "property 1",
            DataTypeId  = -88,
            GroupId     = 222,
            Label       = "Prop 1",
            Validation  = new PropertyTypeValidation
            {
                Mandatory        = true,
                MandatoryMessage = "Please enter a value",
                Pattern          = "xyz",
                PatternMessage   = "Please match the pattern"
            }
        };

        var result = _sut.Map <IPropertyType>(basic);

        Assert.AreEqual(basic.Id, result.Id);
        Assert.AreEqual(basic.SortOrder, result.SortOrder);
        Assert.AreEqual(basic.Alias, result.Alias);
        Assert.AreEqual(basic.Description, result.Description);
        Assert.AreEqual(basic.DataTypeId, result.DataTypeId);
        Assert.AreEqual(basic.Label, result.Name);
        Assert.AreEqual(basic.Validation.Mandatory, result.Mandatory);
        Assert.AreEqual(basic.Validation.MandatoryMessage, result.MandatoryMessage);
        Assert.AreEqual(basic.Validation.Pattern, result.ValidationRegExp);
        Assert.AreEqual(basic.Validation.PatternMessage, result.ValidationRegExpMessage);
        Assert.AreEqual(basic.LabelOnTop, result.LabelOnTop);
    }
Ejemplo n.º 3
0
 // Umbraco.Code.MapAll -Editor -View -Config -ContentTypeId -ContentTypeName -Locked
 private static void Map(MemberPropertyTypeBasic source, MemberPropertyTypeDisplay target, MapperContext context)
 {
     target.Alias = source.Alias;
     target.AllowCultureVariant = source.AllowCultureVariant;
     target.DataTypeId          = source.DataTypeId;
     target.Description         = source.Description;
     target.GroupId             = source.GroupId;
     target.Id                    = source.Id;
     target.Inherited             = source.Inherited;
     target.IsSensitiveData       = source.IsSensitiveData;
     target.Label                 = source.Label;
     target.MemberCanEditProperty = source.MemberCanEditProperty;
     target.MemberCanViewProperty = source.MemberCanViewProperty;
     target.SortOrder             = source.SortOrder;
     target.Validation            = source.Validation;
 }
Ejemplo n.º 4
0
        // no MapAll - take care
        private void Map(MemberTypeSave source, IMemberType target, MapperContext context)
        {
            MapSaveToTypeBase <MemberTypeSave, MemberPropertyTypeBasic>(source, target, context);
            MapComposition(source, target, alias => _memberTypeService.Get(alias));

            foreach (MemberPropertyTypeBasic propertyType in source.Groups.SelectMany(x => x.Properties))
            {
                MemberPropertyTypeBasic localCopy = propertyType;
                IPropertyType           destProp  =
                    target.PropertyTypes.SingleOrDefault(x => x.Alias.InvariantEquals(localCopy.Alias));
                if (destProp == null)
                {
                    continue;
                }

                target.SetMemberCanEditProperty(localCopy.Alias, localCopy.MemberCanEditProperty);
                target.SetMemberCanViewProperty(localCopy.Alias, localCopy.MemberCanViewProperty);
                target.SetIsSensitiveProperty(localCopy.Alias, localCopy.IsSensitiveData);
            }
        }