NHibernate testing, mocking ISession
问题 I am using NHibernate and Rhinomocks and having trouble testing what I want. I would like to test the following repository method without hitting the database (where _session is injected into the repository as ISession): public class Repository : IRepository { (... code snipped for brevity ...) public T FindBy<T>(Expression<Func<T, bool>> where) { return _session.Linq<T>().Where(where).FirstOrDefault(); } } My initial approach is to mock ISession, and return an IQueryable stub (hand coded)