Definitions
In ASP.NET MVC, there are two ways to do model binding in an action. Let's call these the "Bind arguments way" and the "UpdateModel way." Both of them do almost exactly the same thing, and they do it in almost exactly the same way:
public ActionResult UpdateWithBindArguments(Foo model)
{
Repository.Update(model);
// error handling removed
return RedirectToAction(...)
}
public ActionResult UpdateWithUpdateModel()
{
Foo model;
UpdateModel(model); // part of MVC framework
Repository.Update(model);
// error handling removed
return RedirectToAction(...)
}
As I said, these do almost exactly the same thing. The first is maybe slightly more readable, but I can get over that.
Two Ways to Test
The important difference, I think, is how you unit test them:
[TestMethod]
public void TestUpdateWithBindArguments()
{
var model = new Foo() { PropertyName = "Bar" };
var controller = new FooController();
var result = controller.UpdateWithBindArguments(model);
// assert
}
[TestMethod]
public void TestUpdateWithUpdateModel()
{
var formData = new FormCollection() { { "PropertyName", "Bar" } };
var controller = new FooController();
controller.ValueProvider = formData.ToValueProvider();
var result = controller.UpdateWithUpdateModel();
// assert
}
The first method builds a model using strong, static typing. The second constructs submitted user data with name/value pairs. I find the first method a little easier to read, but the second method much closer to what actually happens when the controller is invoked by a web site.
For reasons well outside the scope of this question, I've never been of the persuasion that one should build aspx pages using lambda expressions instead of strings for model binding. I'd be happy to have that discussion with you, but let's not do it here. For the purpose of this question, let's take it for granted that I will be using the built-in HtmlHelper methods which take strings instead of extensions to it which take lambda expressions. Therefore, the second method's use of name/value pairs has some value as an informal test against the "dynamic" nature of the aspx pages. Of course, it does not replace integration testing against the site.
The Question (Finally!)
I see advantages and disadvantages to both methods. My question is, is there a really strong argument in favor of one method which I am missing?
Edit I am looking for objective answers. I am looking for non-obvious reasons why one method is better than the other, not trying to take an opinion poll.