Exemplo n.º 1
0
        public void it_should_unflatten_components_into_property()
        {
            container.Map <ViewModelComponent>().From <FlattenedComponentEvent>().Redirecting <FlattenedComponentEvent>(
                from => from.DifferentName, to => to.Name);
            container.Map <ComplexViewModel>()
            .From <FlattenedComponentEvent>()
            .UsingValue <FlattenedComponentEvent>("blah", to => to.Name)
            .Unflattening <FlattenedComponentEvent>(to => to.Component);
            var bindable = container.ToBinding();

            bindable.Bind();
            bindable.Assert();

            var source = new FlattenedComponentEvent()
            {
                DifferentName = "FlattenedName",
            };
            var dest       = new ComplexViewModel();
            var executable = bindable.CreateCommand(typeof(FlattenedComponentEvent), typeof(ComplexViewModel));

            executable.Map(source, dest);
            dest.Component.should_not_be_null();
            dest.Component.Name.should_be_equal_to("FlattenedName");
        }
Exemplo n.º 2
0
        public void it_should_unflatten_components_into_property()
        {
            container.Map<ViewModelComponent>().From<FlattenedComponentEvent>().Redirecting<FlattenedComponentEvent>(
                from => from.DifferentName, to => to.Name);
            container.Map<ComplexViewModel>()
                .From<FlattenedComponentEvent>()
                .UsingValue<FlattenedComponentEvent>("blah",to=>to.Name)
                .Unflattening<FlattenedComponentEvent>(to=>to.Component);
            var bindable = container.ToBinding();
            bindable.Bind();
            bindable.Assert();

            var source = new FlattenedComponentEvent() { DifferentName = "FlattenedName", };
            var dest = new ComplexViewModel();
            var executable = bindable.CreateCommand(typeof(FlattenedComponentEvent), typeof(ComplexViewModel));
            executable.Map(source, dest);
            dest.Component.should_not_be_null();
            dest.Component.Name.should_be_equal_to("FlattenedName");
        }