I hate to post about databinder stuff, but this seems odd.
What is the expected behaviour binding to a params dictionary like:
params["obj.SomeList[0]"]="123"
params["obj.SomeList[1]"]="456"
params["obj.SomeList[2]"]=""
params["obj.SomeList[3]"]=""

I swear DataBinder used to add 2 items to obj.SomeList (List<double?>)
but I just moved to IIS7/server 2008 and now it doesn't add any values
at all. However if 'null' is the value instead of empty strings then
it works just fine.

I am using today's trunk.

Here are tests demonstrating...
The first test here PASSES, but the other two FAIL...note that NULL
values allow DataBinder to create and hydrate the list as expected.
Has anyone else come against this?:

public class when_binding_indexed_properties_with_null_list_itemas :
context_spec
{
        private ControllerBindingLIst sut;
        private StubMonoRailServices services;
        private IControllerContext controllerContext;
        private StubEngineContext engineContext;

        public override void establish_context()
        {
                services = new StubMonoRailServices();
                sut = new ControllerBindingLIst();
                controllerContext = services.ControllerContextFactory
                        .Create("", "home", "MyAction",
services.ControllerDescriptorProvider.BuildDescriptor(sut));


                engineContext = new StubEngineContext();
                engineContext.Request.Params.Add("entity.List[0]", "123");
                engineContext.Request.Params.Add("entity.List[1]", "456");
                engineContext.Request.Params.Add("entity.List[2]", null); //
databinder recognizes this
                engineContext.Request.Params.Add("entity.List[3]", null);//
databinder recognizes this


        }

        public override void because()
        {
                //given
                sut.Process(engineContext, controllerContext);
        }
        [Observation]
        public void should_not_be_null()
        {
                Assert.NotNull(sut.list);
        }
        [Observation]
        public void should_have_two_list_items()
        {
                Assert.Equal(2, sut.list.Count); //passes
        }

}
public class when_binding_indexed_properties_with_empty_list_items :
context_spec
{
        private ControllerBindingLIst sut;
        private StubMonoRailServices services;
        private IControllerContext controllerContext;
        private StubEngineContext engineContext;

        public override void establish_context()
        {
                services = new StubMonoRailServices();
                sut = new ControllerBindingLIst();
                controllerContext = services.ControllerContextFactory
                        .Create("", "home", "MyAction",
services.ControllerDescriptorProvider.BuildDescriptor(sut));


                engineContext = new StubEngineContext();
                engineContext.Request.Params.Add("entity.List[0]", "123");
                engineContext.Request.Params.Add("entity.List[1]", "456");
                engineContext.Request.Params.Add("entity.List[2]", 
"");//databinder
consequently disregards all values
                engineContext.Request.Params.Add("entity.List[3]", "");


        }

        public override void because()
        {
                //given
                sut.Process(engineContext,controllerContext);


        }
        [Observation]
        public void should_not_be_null()
        {
                Assert.NotNull(sut.list);
        }
        [Observation]
        public void should_have_two_list_items()
        {
                Assert.Equal(2,sut.list.Count); //FAILS, saying zero  items are 
in
the list
        }

}
public class when_binding_repeated_properties_on_sdc : context_spec
{
        private ControllerBindingLIst sut;
        private StubMonoRailServices services;
        private IControllerContext controllerContext;
        private StubEngineContext engineContext;

        public override void establish_context()
        {
                services = new StubMonoRailServices();
                sut = new ControllerBindingLIst();
                controllerContext = services.ControllerContextFactory
                        .Create("", "home", "MyAction",
services.ControllerDescriptorProvider.BuildDescriptor(sut));


                engineContext = new StubEngineContext();
                engineContext.Request.Params.Add("entity.List", "123");
                engineContext.Request.Params.Add("entity.List", "456");
                engineContext.Request.Params.Add("entity.List", "");
                engineContext.Request.Params.Add("entity.List", "");

        }

        public override void because()
        {
                //given
                sut.Process(engineContext, controllerContext);


        }
        [Observation]
        public void should_not_be_null()
        {
                Assert.NotNull(sut.list);
        }
        [Observation]
        public void should_have_two_list_items()
        {
                Assert.Equal(2, sut.list.Count); //same thing...fails saying 
zero
items are in list
        }

}

//ENTITIES USED
public class ObjWithList
{
        List<double?> list=new List<double?>();

        public List<double?> List
        {
                get { return list; }
                set { list = value; }
        }
}

public class ControllerBindingLIst:SmartDispatcherController
{
        public List<double?> list;

        public void MyAction([DataBind("entity")] ObjWithList entity)
        {
                this.list = entity.List;
        }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to