I have a class ProductControllerand Product. Each time an action is called Createin ProductController, it creates a new Productone based on FormCollection, and then calls a function inside Productto change the date:
[HttpPost]
public ActionResult Create(FormCollection form)
{
Product product = new Product();
TryUpdateModel(product, form);
if(ModelState.IsValid)
{
product.ChangeDate(form["date"]);
repository.SaveProduct(product);
return RedirectToAction("Index");
}
else
return View();
}
I was wondering how I can check Product, so I know what .ChangeDateis being called (via Moq Verify). I did not use the automatic binding of the Asp.Net model because I want to catch any binding exception through TryUpdateModel. I'm not sure if I should put .ChangeDatein a Controller or Repository class. I am using Moq, MVC3 and Entity Framework 4. Any help is appreciated!
Thanks Alex
source