I would look into NDBUnit so that you can create repeatability in your tests by making your DB in a consistent state for each test. And even thinking about using an in memory database (sqlite) for your tests.
I have tried mocking out session and criteria and it is just too painful in most cases. I found that using NDBUnit allows me to test my repository layer in a way that works for me. Cheers Stefan On Tue, Dec 16, 2008 at 8:29 AM, vitalya <[email protected]> wrote: > > Hello everyone, > > What are the best options to test Finder pattern by Ayende (http:// > ayende.com/Blog/archive/2006/12/07/ > ComplexSearchingQueryingWithNHibernate.aspx)? I've been using this > pattern in the projects, that almost had no unit tests, and now after > some investigation it turned out that to test such code is not a piece > of cake. Neither DetachedCriteria nor ICriteria do not provide public > interface for getting Criterions \ Restrictions, that were set in the > Add method. After some discussions within a team we see 2 not cool > options: > 1. Provide ISession mock to GetExecutableCriteria method, cast > ICriteria to CriteriaImpl and assert it > 2. Make kind of integration tests and run the query against the test > database, with pre-created test data. > > Are we missing something? What are the best practices for such case? > > Thanks in advance! > > > > -- Stefan Sedich Software Developer http://weblogs.asp.net/stefansedich --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
