I'm just starting my first MVC3 application, and I'm not sure how to unit-test it. I was planning to break out helper classes (static helpers, usually) into a separate assembly, as well as model classes, so that I could test them with NUnit.
So I'm OK on helper classes; but how do I test model classes (considering that they're annotated for NHibernate and tied to the database), and how can I test my views and controllers?
What are the specific tools and techniques I need to test NHibernate-bound models, as well as ASP.NET views and controllers? I'm not sure. NUnit only solves some of the problem.
Edit: Here's some samples of code -- I'm not on my dev machine right now, so I don't have real code to show-case.
- Models: Anything from the ActiveRecord documentation
- Controllers: The standard HomeController from the MVC3 documentation
- Views: Any strongly-typed view (let's say Create) generated from the right-click context menu (Add > View)
Specific questions:
- How I can test saving models without actually saving to the main/production database
- Scope for testing views; should I simply test fields exist? What about validation error messages?
- Controllers: scope for testing. Should I test that actions touch and deform database data as expected (eg. /get/id gets that object; /delete/id deletes that object)?