public void DropDownMultipleValueEditor_Format_Data_For_Cache()
        {
            var dataValueEditorFactoryMock = new Mock <IDataValueEditorFactory>();
            var serializer = new ConfigurationEditorJsonSerializer();
            var checkBoxListPropertyEditor = new CheckBoxListPropertyEditor(dataValueEditorFactoryMock.Object, Mock.Of <ILocalizedTextService>(), Mock.Of <IIOHelper>(), Mock.Of <IEditorConfigurationParser>());
            var dataType = new DataType(checkBoxListPropertyEditor, serializer)
            {
                Configuration = new ValueListConfiguration
                {
                    Items = new List <ValueListConfiguration.ValueListItem>
                    {
                        new ValueListConfiguration.ValueListItem {
                            Id = 4567, Value = "Value 1"
                        },
                        new ValueListConfiguration.ValueListItem {
                            Id = 1234, Value = "Value 2"
                        },
                        new ValueListConfiguration.ValueListItem {
                            Id = 8910, Value = "Value 3"
                        }
                    }
                },
                Id = 1
            };

            var dataTypeServiceMock = new Mock <IDataTypeService>();

            dataTypeServiceMock
            .Setup(x => x.GetDataType(It.IsAny <int>()))
            .Returns(dataType);

            //TODO use builders instead of this mess
            var multipleValueEditor = new MultipleValueEditor(Mock.Of <ILocalizedTextService>(), Mock.Of <IShortStringHelper>(), Mock.Of <IJsonSerializer>(), Mock.Of <IIOHelper>(), new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"));

            dataValueEditorFactoryMock
            .Setup(x => x.Create <MultipleValueEditor>(It.IsAny <DataEditorAttribute>()))
            .Returns(multipleValueEditor);

            var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), dataType));

            prop.SetValue("Value 1,Value 2,Value 3");

            IDataValueEditor valueEditor = dataType.Editor.GetValueEditor();

            ((DataValueEditor)valueEditor).Configuration = dataType.Configuration;
            var result = valueEditor.ConvertDbToString(prop.PropertyType, prop.GetValue());

            Assert.AreEqual("Value 1,Value 2,Value 3", result);
        }
Beispiel #2
0
 public void DropDownMultipleValueEditor_Format_Data_For_Cache()
 {
     var dataValueEditorFactoryMock = new Mock <IDataValueEditorFactory>();
     var serializer = new ConfigurationEditorJsonSerializer();
     var checkBoxListPropertyEditor = new CheckBoxListPropertyEditor(
         dataValueEditorFactoryMock.Object,
         Mock.Of <ILocalizedTextService>(),
         Mock.Of <IIOHelper>(),
         Mock.Of <IEditorConfigurationParser>());
     var dataType = new DataType(checkBoxListPropertyEditor, serializer)
     {
         Configuration = new ValueListConfiguration
         {
             Items = new List <ValueListConfiguration.ValueListItem>
             {
                 new() { Id = 4567, Value = "Value 1" },
                 new() { Id = 1234, Value = "Value 2" },
                 new() { Id = 8910, Value = "Value 3" },
             },
         },