Click here to see the series overview
After recording Part 1, I tried to dive right into an episode about testing models but I found myself doing lots of clean-up. So I decided to stop and record an episode just to clean up our code!
TDD MVC - Part 2
In this episode, we:
- Setup our site on IIS (no more Cassini!)
- Configure our database (no more magical EntityFramework database detection!)
- Setup our DbContext so it’s easy to access from our MVC app and tests
- Setup our tests so they use inheritance to share functionality
Disclaimer
When we setup our DbContext, we don’t use Dependency Injection! Oh noes!
Feel free to use your favorite DI library (as I point out in the screencast). The important thing is: you’re eventually going to want to be able to override your context from your tests so you can make your tests run transactionally (which we’ll cover in a future episode).
That said, you don’t have to use DI (just because the cool kids are doing it). I don’t use DI in my personal apps so don’t feel bullied into using it, if you don’t feel like you actually need it :)