Mocking ISession.Query <T> () for consumer testing
I am trying to avoid using a database in memory for testing (although I may have to do this if the following is not possible). I am using NHibernate 3.0 with LINQ. I would like to be able to scoff at session.Query<T>()to return some dummy values, but I cannot, as this is an extension method, and it is almost impossible to verify.
Does anyone have any suggestions (other than using a database in memory) for testing session requests using LINQ?
A better approach would be to falsify the concept of what you are trying to do, rather than the internal api of the external system. For instance,
- Write the query in a split artifact like IQuerySomething / QuerySomething
- Check your database request. Try this database to be prety like real db.
- When testing something that depends on IQuerySomething, mock IQuerySomething.
Fabio Molo wrote about this template as an EQO (Extended Request Object), I recommend you post it.
.net .
, . =)
, , ( , , ). . ( , , "" ), .
, - .
, , , , , Fluent Nhibernate ( ) ), .
, , ( Linq), . , , , :
get-customer-by-name, .
, . .
, , José F. Romaniello, Enhanced Query Object .
Sharp Arhitecture framework, Nhibernate .