180 likes | 314 Views
Tying It All Together . Dealing with HttpContext , etc. Things that will make your code untestable :. public ActionResult Index() { Session[“ foo ”] = “bar”; var productName = Request.Form [“Product_3_Name”]; }. Dealing with HttpContext , etc. Use HttpInterfaces instead!.
E N D
Dealing with HttpContext, etc. Things that will make your code untestable: public ActionResult Index() { Session[“foo”] = “bar”; varproductName = Request.Form[“Product_3_Name”]; }
Dealing with HttpContext, etc. Use HttpInterfaces instead! public OrderController(IHttpSession session, IHttpRequest request) { _session = session; _request = request; } public ActionResult Index() { _session[“foo”] = “bar”; varproductName = _request.Form[“Product_3_Name”]; } Now we have interfaces instead of unmockable abstract base classes!
Cucumber/SpecFlow Write executable specifications that drive a browser Given I am a logged in user And there are products in my cart When I click the “New Order” link Then the list of products in my cart should be empty
Slides, links, code, contact info Slides, code, links: http://jonkruger.com/blog/tdd-immersion Email: jon@jonkruger.com Twitter: @JonKruger Blog: http://jonkruger.com/blog