public async Task CombinableEnum()
        {
            var enumObj = new EnumClass();

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(enumObj);

            List <int> values = new List <int> ();

            values.Add((int)FlagsTestEnum.Flag1);
            values.Add((int)FlagsTestEnum.Flag3);

            FlagsTestEnum expected = FlagsTestEnum.Flag1 | FlagsTestEnum.Flag3;

            await editor.SetValueAsync(editor.Properties.First(), new ValueInfo <IReadOnlyList <int> > {
                Value = values
            });

            ValueInfo <int> underlying = await editor.GetValueAsync <int> (editor.Properties.First());

            Assert.That((FlagsTestEnum)underlying.Value, Is.EqualTo(expected));

            ValueInfo <IReadOnlyList <int> > underlyingList = await editor.GetValueAsync <IReadOnlyList <int> > (editor.Properties.First());

            Assert.That(underlyingList.Value, Contains.Item((int)FlagsTestEnum.Flag1));
            Assert.That(underlyingList.Value, Contains.Item((int)FlagsTestEnum.Flag3));
        }
Пример #2
0
        public async Task PropertyListCategoryFiltered()
        {
            var provider = new ReflectionEditorProvider();
            var obj      = new TestClassSub();
            var editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(2));

            var vm = new PanelViewModel(new TargetPlatform(provider))
            {
                ArrangeMode = PropertyArrangeMode.Category
            };

            vm.SelectedObjects.Add(obj);

            Assume.That(vm.ArrangedEditors, Is.Not.Empty);

            vm.FilterText = "sub";
            Assert.That(vm.ArrangedEditors.Count, Is.EqualTo(1));

            var group = vm.ArrangedEditors.FirstOrDefault(g => g.Category == "Sub");

            Assert.That(group, Is.Not.Null);
            Assert.That(group.Editors.Count, Is.EqualTo(1));
        }
        public async Task PropertyChanged()
        {
            var obj = new TestClass();

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(obj);

            const string value    = "value";
            var          property = editor.Properties.Single();

            bool changed = false;

            editor.PropertyChanged += (sender, args) => {
                if (Equals(args.Property, property))
                {
                    changed = true;
                }
            };

            await editor.SetValueAsync(property, new ValueInfo <string> {
                Value = value
            });

            Assert.That(changed, Is.True, "PropertyChanged was not raised for the given property");
        }
        public async Task DontSetupPropertiesMarkedUnbrowsable()
        {
            var unbrowsable = new Unbrowsable();

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(unbrowsable);

            Assert.That(editor.Properties.Count, Is.EqualTo(1), "Wrong number of properties");
            Assert.That(editor.Properties.Single().Name, Is.EqualTo(nameof(Unbrowsable.VisibleProperty)));
        }
        public async Task EditorHasSimpleProperty()
        {
            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(new TestClass());

            Assume.That(editor, Is.Not.Null);

            Assert.That(editor.Properties.Count, Is.EqualTo(1));

            var property = editor.Properties.Single();

            Assert.That(property.Name, Is.EqualTo(nameof(TestClass.Property)));
            Assert.That(property.Type, Is.EqualTo(typeof(string)));
        }
Пример #6
0
        public async Task PropertiesAddedFromEditor()
        {
            var provider = new ReflectionEditorProvider();
            var obj      = new TestClass();
            var editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(1));

            var vm = new PanelViewModel(provider, TargetPlatform.Default);

            vm.SelectedObjects.Add(obj);

            Assert.That(vm.Properties, Is.Not.Empty);
            Assert.That(((PropertyViewModel)vm.Properties[0]).Property, Is.EqualTo(editor.Properties.Single()));
        }
        public async Task GetValueConvert()
        {
            const string value = "1";
            var          obj   = new TestClass {
                Property = value
            };

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(obj);

            ValueInfo <int> info = await editor.GetValueAsync <int> (editor.Properties.Single());

            Assert.That(info.Value, Is.EqualTo(1));
            Assert.That(info.Source, Is.EqualTo(ValueSource.Local));
        }
        public async Task SetValueConvert()
        {
            var obj = new TestClass();

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(obj);

            const string value = "1";

            await editor.SetValueAsync(editor.Properties.Single(), new ValueInfo <int> {
                Value = 1
            });

            Assert.That(obj.Property, Is.EqualTo(value));
        }
Пример #9
0
        public async Task PropertyCategoryArrange()
        {
            var provider = new ReflectionEditorProvider();
            var obj      = new TestClassSub();
            var editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(2));

            var vm = new PanelViewModel(provider, TargetPlatform.Default)
            {
                ArrangeMode = PropertyArrangeMode.Category
            };

            vm.SelectedObjects.Add(obj);

            Assume.That(vm.ArrangedEditors, Is.Not.Empty);
            Assert.That(vm.ArrangedEditors.FirstOrDefault(g => g.Key == "Sub"), Is.Not.Null);
        }
        public async Task TypeConvertFromPropertyAttribute()
        {
            const string value = "value";
            var          obj   = new ConversionClass2();

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(1));

            await editor.SetValueAsync(editor.Properties.Single(), new ValueInfo <string> {
                Value  = value,
                Source = ValueSource.Local
            });

            Assert.That(obj.Property, Is.Not.Null);
            Assert.That(obj.Property.Property, Is.EqualTo(value));
        }
Пример #11
0
        public async Task PropertyListFilteredTextReducesList()
        {
            var provider = new ReflectionEditorProvider();
            var obj      = new TestClassSub();
            var editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(2));

            var vm = new PanelViewModel(new TargetPlatform(provider));

            Assume.That(vm.ArrangeMode, Is.EqualTo(PropertyArrangeMode.Name));
            vm.SelectedObjects.Add(obj);

            Assume.That(vm.ArrangedEditors, Is.Not.Empty);
            Assume.That(vm.ArrangedEditors[0].Editors.Count, Is.EqualTo(2));

            vm.FilterText = "sub";
            Assert.That(vm.ArrangedEditors[0].Editors.Count, Is.EqualTo(1));
        }
Пример #12
0
        public async Task AutoExpand()
        {
            var provider = new ReflectionEditorProvider();
            var obj      = new TestClassSub();
            var editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(2));

            var vm = new PanelViewModel(new TargetPlatform(provider))
            {
                ArrangeMode = PropertyArrangeMode.Category,
                AutoExpand  = true
            };

            vm.SelectedObjects.Add(obj);

            Assume.That(vm.ArrangedEditors, Is.Not.Empty);
            Assert.That(vm.GetIsExpanded(vm.ArrangedEditors[0].Category), Is.True);
        }
        public async Task TypeConverterToPropertyAttribute()
        {
            const string value = "value";
            var          obj   = new ConversionClass2 {
                Property = new TestClass2 {
                    Property = value
                }
            };

            var           provider = new ReflectionEditorProvider();
            IObjectEditor editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(1));

            ValueInfo <string> info = await editor.GetValueAsync <string> (editor.Properties.Single());

            Assert.That(info.Value, Is.EqualTo(value));
            Assert.That(info.Source, Is.EqualTo(ValueSource.Local));
        }
Пример #14
0
        public async Task PropertyListIsFiltered()
        {
            var provider = new ReflectionEditorProvider();
            var obj      = new TestClassSub();
            var editor   = await provider.GetObjectEditorAsync(obj);

            Assume.That(editor.Properties.Count, Is.EqualTo(2));

            var vm = new PanelViewModel(new TargetPlatform(provider));

            Assume.That(vm.ArrangeMode, Is.EqualTo(PropertyArrangeMode.Name));
            vm.SelectedObjects.Add(obj);

            Assume.That(vm.ArrangedEditors, Is.Not.Empty);
            Assume.That(vm.ArrangedEditors[0].Editors.Count, Is.EqualTo(2));

            Assume.That(vm.IsFiltering, Is.False);
            bool changed = false;

            vm.PropertyChanged += (sender, args) => {
                if (args.PropertyName == nameof(PanelViewModel.IsFiltering))
                {
                    changed = true;
                }
            };

            vm.FilterText = "sub";
            Assume.That(vm.ArrangedEditors[0].Editors.Count, Is.EqualTo(1));
            Assert.That(vm.IsFiltering, Is.True);
            Assert.That(changed, Is.True);
            changed = false;

            vm.FilterText = null;
            Assert.That(vm.IsFiltering, Is.False);
            Assert.That(changed, Is.True);
        }