public void GetValueTest()
        {
            var dataTypeService = Mock.Of <IDataTypeService>();

            var propListDataType = new DataTypeDefinition("propListEditorAlias")
            {
                Id           = 1,
                Key          = Guid.Parse("74AFF355-537A-4443-9801-C131FE83FF1F"),
                DatabaseType = DataTypeDatabaseType.Ntext
            };

            var innerDataType = new DataTypeDefinition("innerEditorAlias")
            {
                Id           = 2,
                Key          = Guid.Parse("D21BA417-98AC-4D05-8EF9-0ED3D75A8C0D"),
                DatabaseType = DataTypeDatabaseType.Integer // for true/false
            };

            var dataTypes = new[] { propListDataType, innerDataType };

            Mock.Get(dataTypeService)
            .Setup(x => x.GetDataTypeDefinitionById(It.IsAny <Guid>()))
            .Returns <Guid>(id => dataTypes.FirstOrDefault(x => x.Key == id));

            var preValues = new Dictionary <int, PreValueCollection>
            {
                { 1, new PreValueCollection(new Dictionary <string, PreValue>
                    {
                        { "dataType", new PreValue(innerDataType.Key.ToString()) }
                    }) }
            };

            Mock.Get(dataTypeService)
            .Setup(x => x.GetPreValuesCollectionByDataTypeId(It.IsAny <int>()))
            .Returns <int>(id => preValues.TryGetValue(id, out var collection) ? collection : null);

            ValueConnectorCollection connectors = null;
            var defaultConnector  = new DefaultValueConnector();
            var propListConnector = new PropertyListValueConnector(dataTypeService, new Lazy <ValueConnectorCollection>(() => connectors));

            connectors = new ValueConnectorCollection(new Dictionary <string, IValueConnector>
            {
                { "innerEditorAlias", defaultConnector },
                { "propListEditorAlias", propListConnector }
            });

            var input = $"{{\"dtd\":\"{innerDataType.Key}\",\"values\":[0]}}";

            var propertyType = new PropertyType(propListDataType);
            var property     = new Property(propertyType, input);
            var dependencies = new List <ArtifactDependency>();
            var output       = propListConnector.GetValue(property, dependencies);

            Console.WriteLine(output);

            var expected = $"{{\"dtd\":\"{innerDataType.Key}\",\"values\":[\"i0\"]}}";

            Assert.AreEqual(expected, output);
        }
        public void SetValueTest()
        {
            var dataTypeService = Mock.Of <IDataTypeService>();

            var propListDataType = new DataTypeDefinition("propListEditorAlias")
            {
                Id           = 1,
                Key          = Guid.Parse("74AFF355-537A-4443-9801-C131FE83FF1F"),
                DatabaseType = DataTypeDatabaseType.Ntext
            };

            var innerDataType = new DataTypeDefinition("innerEditorAlias")
            {
                Id           = 2,
                Key          = Guid.Parse("D21BA417-98AC-4D05-8EF9-0ED3D75A8C0D"),
                DatabaseType = DataTypeDatabaseType.Integer // for true/false
            };

            var dataTypes = new[] { propListDataType, innerDataType };

            Mock.Get(dataTypeService)
            .Setup(x => x.GetDataTypeDefinitionById(It.IsAny <Guid>()))
            .Returns <Guid>(id => dataTypes.FirstOrDefault(x => x.Key == id));

            var preValues = new Dictionary <int, PreValueCollection>
            {
                { 1, new PreValueCollection(new Dictionary <string, PreValue>
                    {
                        { "dataType", new PreValue(innerDataType.Key.ToString()) }
                    }) }
            };

            Mock.Get(dataTypeService)
            .Setup(x => x.GetPreValuesCollectionByDataTypeId(It.IsAny <int>()))
            .Returns <int>(id => preValues.TryGetValue(id, out var collection) ? collection : null);

            ValueConnectorCollection connectors = null;
            var defaultConnector  = new DefaultValueConnector();
            var propListConnector = new PropertyListValueConnector(dataTypeService, new Lazy <ValueConnectorCollection>(() => connectors));

            connectors = new ValueConnectorCollection(new Dictionary <string, IValueConnector>
            {
                { "innerEditorAlias", defaultConnector },
                { "propListEditorAlias", propListConnector }
            });

            var input = $"{{\"dtd\":\"{innerDataType.Key}\",\"values\":[\"i0\"]}}";

            UmbracoConfig.For.SetUmbracoSettings(GenerateMockSettings());

            var propListPropertyType = new PropertyType(propListDataType, "propListProperty");
            var propListProperty     = new Property(propListPropertyType, null); // value is going to be replaced
            var propListContent      = new Content("mockContent", -1, new ContentType(-1), new PropertyCollection(new List <Property> {
                propListProperty
            }));

            propListConnector.SetValue(propListContent, "propListProperty", input);

            var output = propListContent.GetValue("propListProperty");

            Assert.IsInstanceOf <string>(output);

            Console.WriteLine(output);

            var expected = $"{{\"dtd\":\"{innerDataType.Key}\",\"values\":[0]}}";

            Assert.AreEqual(expected, output);
        }