code_junkie

Unit testing with ASP.NET MVC model binders

Nov 13th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. [AcceptVerbs(HttpVerbs.Get)]
  2. public ActionResult AddProduct(Product product)
  3. {
  4. }
  5.  
  6. public void Catalog_AddProduct()
  7. {
  8. CatalogController controller = new CatalogController();
  9. // some mocking for controller context, setting form values etc...
  10. controller.AddProduct(// ?);
  11. }
  12.  
  13. [TestMethod()]
  14. public void AddProductTest()
  15. {
  16. CatalogController target = new CatalogController(/*testing variables*/);
  17. target.AddProduct(new Product { /* product details for testing */ });
  18.  
  19. // Test the results
  20. }
Add Comment
Please, Sign In to add comment