Before using MVC 2 RC I was using MVC 1, the code I used to update my object in my controller was this:
TryUpdateModel(entity, null, null, new[] { "Name", "Controller" });
I was able to Unit Test this controller action just using this in my test:
controller.ValueProvider = myFormCollection.ToValueProvider();
After migrating my code to MVC 2 this no longer works. It keeps failing in the GetValue method implementation in FormCollection, because it verifies that the value you're asking it for is not null or empty. The thing is this code works in runtime, but not in my unit test. I'm not using a prefix so I'm sending NULL as a prefix value.
I've looked in the MVC 2 RC source code and the first value the ValueProvider of the controller looks for is the prefix, so it fails horribly. What provider do I have to assign to controller.ValueProvider so that it can work in my unit test?
Edit: Asking it very briefly, how do I tell TryUpdateModel to NOT use a prefix in my unit test so that it doesn't throw an exception?
Thanks!