I'd like to write a unit test for my data access layer to make sure that everything works allright in it. The question is, what kind of things should I put into the tests?
The DAL is a static Repository
class which hides the underlying layer (Fluent NHibernate) and exposes stuff to the public through an IQueryable
.
I thought about
Is there anything else about a DAL that is worth testing?
Thanks in advance for your answers!
Repository implementation is tested with integration tests, not unit tests. Isolating repository implementation (mocking ORM) is almost impossible. Please take a look at this answer. Integration test uses a real ORM combined with real or fake (usually in-memory) database to do following:
Essentially you testing the correctness of:
Transactions are usually handled by an application layer, not repositories. You might be interested in this answer. Encapsulating IQueryable in the repository implementation will make testing a lot easier for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With