views:

150

answers:

2

Hi!

I read the Book NHibernate in Action and there it is speaking about testing the persistence layer/data abstraction layer. You can test two ways. The mapping-test and the persistence logic-test. Accoring to the book testing the mapping means that entities are correctly loaded and saved.

But what's about update's and delete's?

By now I use Fluent NHibernate and this is also only testing for loading and saving.

How do I test a persistence layer correctly?

A: 

A good guide to unit test patterns can be found here: http://www.codeproject.com/KB/architecture/autp5.aspx

Jay
How does this help me?
Rookian
Q: "How do I test a persistence layer correctly?" A: Use the test patterns given in the discussion of unit testing in the provided link
Jay
+4  A: 

On past projects, I've written NUnit tests that exercised the update and delete NHibernate logic against a SQLite DB.

I'm not advocating this as the correct way to do things though. I'd be reasonably comfortable that if NHibernate is successfully performing saves and loads, it'll be able to update and delete.

antik
+1: I find it easier to test with the persistence layer in place. I don't mock this kind of thing. I build a test database and just exercise my code and check the effects in the test database. Yes it's not a *pure* unit test, but it's close enough to pure, and it happens to use the ORM/persistence to check results in the database.
S.Lott