I am using NUnit for test units. I have my interface on the domain so i am ready to make implementation of those interfaces in the persistence layer. My question is how do you actually make the unit tests for testing those repositories ? i believe this isnt a good idea to test directly from the database. Ive heard poeple that are using SQLite but it is okay to use mocks instead ? why are the poeple using SQLite for in-memory database when you can provide a mock with actuals entities ?
Any example would be welcome too.
Note: This is intended to be repositories coded in C# that gonna use NHibernate and Fluent NHibernate as mapping.
Thanks.
It of course depends, but in most cases I'd say it's generally enough to just mock the repositories in your tests and using the in-memory SQLite database only to test your mappings (FluentNHibernate Persistence specification testing).
For the NUnit mappings tests with SQLite I'm using the following base class:
An example mappings test class deriving from the above base class could then look like the following: