public void set_a_property_correctly_against_a_binding_context()
        {
            var model = new AddressViewModel();
            context.WithData("Localities[0]ZipCode", "84115");
            context.StartObject(model);

            var property = ReflectionHelper.GetProperty<AddressViewModel>(x => x.Localities);
            propertyBinder.Bind(property, context);

            model.Localities[0].ZipCode.ShouldEqual("84115");
        }
        public void existing_collection_is_not_discarded()
        {
            var model = new AddressViewModel
            {
                Localities = new List<LocalityViewModel>
                {
                    new LocalityViewModel {ZipCode = "previously_set_zipcode"}
                }
            };

            context.WithData("Localities[0]ZipCode", "84115");
            context.StartObject(model);

            var property = ReflectionHelper.GetProperty<AddressViewModel>(x => x.Localities);
            propertyBinder.Bind(property, context);

            model.Localities[0].ZipCode.ShouldEqual("previously_set_zipcode");
            model.Localities[1].ZipCode.ShouldEqual("84115");
        }
示例#3
0
        public void existing_collection_is_not_discarded()
        {
            var model = new AddressViewModel
            {
                Localities = new List <LocalityViewModel>
                {
                    new LocalityViewModel {
                        ZipCode = "previously_set_zipcode"
                    }
                }
            };

            context.WithData("Localities[0]ZipCode", "84115");
            context.StartObject(model);

            var property = ReflectionHelper.GetProperty <AddressViewModel>(x => x.Localities);

            propertyBinder.Bind(property, context);

            model.Localities[0].ZipCode.ShouldEqual("previously_set_zipcode");
            model.Localities[1].ZipCode.ShouldEqual("84115");
        }