Пример #1
0
        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();
        }
Пример #2
0
        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();
        }