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)); }
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 SetInitialValuesAsync(IObjectEditor editor) { await editor.SetValueAsync(Properties["FilePath"], new ValueInfo <FilePath> { Value = new FilePath("/Desktop/MyTestFile") }); await editor.SetValueAsync(Properties["DateTime"], new ValueInfo <DateTime> { Value = DateTime.Now }); await editor.SetValueAsync(Properties["Date"], new ValueInfo <Date> { Value = new Date(DateTime.Now) }); await editor.SetValueAsync(Properties["Time"], new ValueInfo <Time> { Value = new Time(DateTime.Now) }); }
public async Task SetReadOnlyBrushInitialValueAsync(IObjectEditor editor, CommonBrush brush) { if (this.readOnlyBrushSet) { return; } await editor.SetValueAsync(this.readOnlyBrushPropertyInfo, new ValueInfo <CommonBrush> { Value = brush }); this.readOnlyBrushSet = true; }
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)); }
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)); }
public async Task SetInitialValuesAsync(IObjectEditor editor) { await editor.SetValueAsync(Properties["FilePath"], new ValueInfo <FilePath> { Value = new FilePath("/Desktop/MyTestFile") }); }