public void entityView_removePropertyMapping_should_remove_property_value() { var value = "Hello world!"; EntityItemViewValueGetter <Object, string> getter = e => { return(e.Item.GetCustomValue <string>(e.PropertyName)); }; EntityItemViewValueSetter <Object, string> setter = e => { e.Item.SetCustomValue(e.PropertyName, e.Value); }; var target = new EntityView <Object>(new[] { new Object() }); target.AddPropertyMapping <string>("Foo", getter, setter); var item = target.First(); item.SetCustomValue <string>("Foo", value); target.RemovePropertyMapping("Foo"); target.AddPropertyMapping <string>("Foo", getter, setter); var actual = target.First().GetCustomValue <string>("Foo"); actual.Should("Not yet implemented").Not.Be.EqualTo(value); actual.Should("Not yet implemented").Be.Null(); }
public void entityItemViewCustomPropertyDescriptor_ctor_customDisplayName_propertyType_valueGetter_should_correctly_set_default_values() { var customPropertyName = "Foo"; EntityItemViewValueGetter <GenericParameterHelper, int> getter = (obj) => { return(null); }; var target = new EntityItemViewCustomPropertyDescriptor <GenericParameterHelper, int>(customPropertyName, getter); target.Category.Should().Be.EqualTo("Misc"); target.Attributes.OfType <Attribute>().Should().Have.SameSequenceAs(new Attribute[0]); target.ComponentType.Should().Be.EqualTo(typeof(IEntityItemView <GenericParameterHelper>)); target.Converter.GetType().Should().Be.EqualTo(typeof(Int32Converter)); target.Description.Should().Be.EqualTo(string.Empty); target.DesignTimeOnly.Should().Be.False(); target.DisplayName.Should().Be.EqualTo(customPropertyName); target.IsBrowsable.Should().Be.True(); target.IsLocalizable.Should().Be.False(); target.IsReadOnly.Should().Be.True(); target.Name.Should().Be.EqualTo(customPropertyName); target.PropertyType.Should().Be.EqualTo(typeof(int)); }
public void entityView_custom_property_mapping_shuold_set_and_get_custom_values_as_expected() { var expected = "Hello World!"; EntityItemViewValueGetter <Object, string> getter = e => { return(e.Item.GetCustomValue <string>(e.PropertyName)); }; EntityItemViewValueSetter <Object, string> setter = e => { e.Item.SetCustomValue(e.PropertyName, e.Value); }; var target = new EntityView <Object>(new[] { new Object() }); target.AddPropertyMapping <string>("Foo", getter, setter); target.First().SetCustomValue("Foo", expected); var actual = target.First().GetCustomValue <string>("Foo"); actual.Should("Not yet implemented").Be.EqualTo(expected); }
public void entityView_removePropertyMapping_should_remove_property_value_even_on_more_then_one_element() { var propertyName = "Foo"; var expectedFirst = "Hello world, from First!"; var expectedLast = "Hello world, from Last!"; EntityItemViewValueGetter <Object, string> getter = e => { return(e.Item.GetCustomValue <string>(e.PropertyName)); }; EntityItemViewValueSetter <Object, string> setter = e => { e.Item.SetCustomValue(e.PropertyName, e.Value); }; var target = new EntityView <Object>(new[] { new Object(), new Object() }); target.AddPropertyMapping <string>(propertyName, getter, setter); var firstItem = target.First(); firstItem.SetCustomValue <string>(propertyName, expectedFirst); var lastItem = target.Last(); lastItem.SetCustomValue <string>(propertyName, expectedLast); target.RemovePropertyMapping(propertyName); target.AddPropertyMapping <string>(propertyName, getter, setter); var actualFirst = target.First().GetCustomValue <string>("Foo"); var actualLast = target.Last().GetCustomValue <string>("Foo"); actualFirst.Should().Be.Null(); actualLast.Should().Be.Null(); }
public EntityItemViewCustomPropertyDescriptor(string customPropertyName, EntityItemViewValueGetter <T, TValue> getter, EntityItemViewValueSetter <T, TValue> setter) : this(customPropertyName) { this.ValueGetter = getter; this.ValueSetter = setter; }
public EntityItemViewCustomPropertyDescriptor(string customPropertyName, EntityItemViewValueGetter <T, TValue> getter) : this(customPropertyName, getter, null) { }