Exemple #1
0
        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();
        }
Exemple #2
0
        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 );
        }
Exemple #3
0
        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);
        }
Exemple #4
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();
        }
Exemple #5
0
        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();
        }
Exemple #6
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();
        }