I have just read this blog post from Jimmy Bogard and was drawn to this comment.
Where this falls down is when a component doesn’t support a given
layering/architecture. But even with NHibernate, I just use the
ISession directly in the controller action these days. Why make things
complicated?
I then commented on the post and ask this question:-
My question here is what options would you have testing the controller logic IF you do not mock out the NHibernate ISession.
I am curious what options we have if we utilise the ISession directly on the controller?
3
Use a light weight in-memory database that’s NHibernate supported.
Or you can use seams on the controller, extract code that uses ISession to a separate method, make it virtual. Override it in a class on which you run your tests.
If you do these methods you may as well put them on a repository interface though.
1