In my project I am using the following approach to querying data from the database:
The answer is (IMO): you should mock Query().
The caveat is: I say this in total ignorance of how Query is defined here - I don't even known NHibernate, and whether it is defined as virtual.
But it probably doesn't matter!Basically what I would do is:
-Mock Query to return a mock IQueryable. (If you can't mock Query because it's not virtual, then create your own interface ISession, which exposes a mockable query, and so on.) -The mock IQueryable doesn't actually analyze the query it is passed, it just returns some predetermined results that you specify when you create the mock.
All put together this basically lets you mock out your extension method whenever you want to.
For more about the general idea of doing extension method queries and a simple mock IQueryable implementation, see here:
http://blogs.msdn.com/b/tilovell/archive/2014/09/12/how-to-make-your-ef-queries-testable.aspx