views:

120

answers:

3

We are currently using SubSonic as our persistence layer because it's light but also because it allows us to feed in test data so our DAL can be tested without hitting the database. I absolutely love that about SubSonic. However, because we are also running into other issues with SubSonic, I'm now looking for an alternative while our project is still young. Long story short, is there another persistence framework for .NET that will allow developers to sub in test data?

A: 

I doubt you will find that particular feature is another .NET ORM, but there is no reason you can't code it yourself. If you want an ORM that scales with your project, NHibernate is the best choice. You may want to poke around Ruby ORMs that run on .NET through IronRuby, but I'm not convinced you'd fine a workable solution.

Michael Maddox
+1  A: 

AFAIK, hNibernate doesn't support for this feature as it is, but it could be achieved if you configure test DB to work in 'in-memory' mode. SQLite supports this mode.

Here is a sample of configuring and tests.

elder_george
A: 

UPDATE: After a lengthy search, we did end up switching to NHibernate as our persistence layer and changing our unit testing philosophy for the repository layer. We concluded that we'll switch to integration testing the repository layer while still unit testing all other layers.

Here's our rationale:

If we just unit test the repository layer, we'll never know how the query will be executed on the database. For example, if we use an in-memory solution like SQLite, all of our specs may pass at development time, but may actually fail once we deploy to production because of 1) differences in how each NHibernate data provider is implemented and 2) differences in how each product (SQLite vs MS MS SQL Server vs Oracle) implements data types, T-SQL, etc.

Jason