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 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 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)); }