8
shouts

SQLite Nunit & Fluent Nhibernate - Test your data access layer

published 143 days, 2 hours, 35 minutes ago posted by http://daniewat82.myopenid.com/http://daniewat82.myopenid.com/ 145 days, 1 hour, 19 minutes ago
Thursday, October 22, 2009 1:22:42 PM GMT Tuesday, October 20, 2009 2:38:54 PM GMT

I think that the worst part of unit testing is that it’s never straight forward to test an applications data access. I always feel worried about just creating in memory collections or objects to test against or mocking data access components. I have found on occasion when the code is switched over from test data to work against an RDBMS issues can occur. What I really want is an in memory database that is created with test data and then disposed of once the tests have been carried out.

Below is a class which will generate an in memory SQLite database based on the model and Nhibernate fluent mappings created (if you don't know how to create the mappings and model then read here). The important line of code here is on line 18 which looks in the assembly where the fluent mappings are located so the framework is able to generate the database schema.

category: Architecture | clicked: 85 | | source: www.dotnetguy.co.uk | show counter code