public void PropertiesAre_NotEmpty()
        {
            var property = new ObjectEnterspeedProperty(
                "test",
                new Dictionary <string, IEnterspeedProperty>()
            {
                ["test"] = new StringEnterspeedProperty("test", "value")
            });

            Assert.NotEmpty(property.Properties);
        }
Ejemplo n.º 2
0
        public IEnterspeedProperty Convert(IPublishedProperty property)
        {
            var value = property.GetValue <string>();

            ObjectEnterspeedProperty mediaValue = null;

            if (!string.IsNullOrWhiteSpace(value) && int.TryParse(value, out var mediaId))
            {
                var media = UmbracoContextHelper.GetUmbracoHelper().TypedMedia(mediaId);
                mediaValue = ConvertToEnterspeedProperty(media);
            }

            return(new ObjectEnterspeedProperty(property.PropertyTypeAlias, mediaValue?.Properties));
        }
        private static List <IEnterspeedProperty> GetCropsProperty(ImageCropperValue value)
        {
            var crops = new List <IEnterspeedProperty>();

            if (value != null && value.Crops != null)
            {
                foreach (var crop in value.Crops)
                {
                    var cropProperties = new Dictionary <string, IEnterspeedProperty>
                    {
                        { "alias", new StringEnterspeedProperty(crop.Alias) },
                        { "height", new NumberEnterspeedProperty(crop.Height) },
                        { "width", new NumberEnterspeedProperty(crop.Width) }
                    };

                    ObjectEnterspeedProperty cropCoordinatesProperty = null;
                    if (crop.Coordinates != null)
                    {
                        var cropCoordinatesProperties = new Dictionary <string, IEnterspeedProperty>
                        {
                            {
                                "X1", new NumberEnterspeedProperty(double.Parse(crop.Coordinates.X1.ToString(CultureInfo.InvariantCulture)))
                            },
                            {
                                "Y1", new NumberEnterspeedProperty(double.Parse(crop.Coordinates.Y1.ToString(CultureInfo.InvariantCulture)))
                            },
                            {
                                "X2", new NumberEnterspeedProperty(double.Parse(crop.Coordinates.X2.ToString(CultureInfo.InvariantCulture)))
                            },
                            {
                                "Y2", new NumberEnterspeedProperty(double.Parse(crop.Coordinates.Y2.ToString(CultureInfo.InvariantCulture)))
                            }
                        };
                        cropCoordinatesProperty = new ObjectEnterspeedProperty(cropCoordinatesProperties);
                    }

                    cropProperties.Add("coordinates", cropCoordinatesProperty);
                    crops.Add(new ObjectEnterspeedProperty(cropProperties));
                }
            }

            return(crops);
        }
        public void TypeIs_Array()
        {
            var property = new ObjectEnterspeedProperty("test", new Dictionary <string, IEnterspeedProperty>());

            Assert.Equal("object", property.Type);
        }
        public void NameIs_Null()
        {
            var property = new ObjectEnterspeedProperty(new Dictionary <string, IEnterspeedProperty>());

            Assert.Null(property.Name);
        }
        public void NameIs_Equal()
        {
            var property = new ObjectEnterspeedProperty("test", new Dictionary <string, IEnterspeedProperty>());

            Assert.Equal("test", property.Name);
        }