views:

218

answers:

1

As the post title implies, I have a legacy database (not sure if that matters), I'm using Fluent NHibernate and I'm attempting to test my mappings using the Fluent NHibernate PersistenceSpecification class.

My question is really a process one, I want to test these when I build locally in Visual Studio using the built in Unit Testing framework for now. Obviously this implies (I think) that I'm going to need a database. What are some options for getting this into the build? If I use an in memory database does NHibernate or Fluent NHibernate have some some mechanism for sucking the database schema from a target database or maybe the in memory database can do this? Will I need to manually get the schema to feed to an in memory database?

Ideally I would like to get this this setup to where the other developers don't really have to think about it other than when they break the build because the tests don't pass.

+1  A: 

NHibernate isn't able to re-create your database's schema and because it's a legacy system you likely won't be able to generate the schema from NH. The best approach is to do your integration tests in transactions and roll them back when complete. We run integration tests against our dev and test databases which are periodically refreshed from the live system.

Jamie Ide
Perhaps am I mistaken, or do I not understand the question properly as English isn't my mothertongue, but as long as the mapping is correct, and that there is a .NET Data Provider for the legacy system whatever it may be, shan't NHibernate be able to export the DB schema?
Will Marcouiller
Your English is fine, my answer could have been better. Unless the database was created from SchemaExport, it's very unlikely that SchemaExport will produce the same schema. With a legacy system I am sure it will be different.
Jamie Ide
So at a high level, I'm going to have to get the schema from SQL Server. I also think I'm going to have to get a smaller version of the database (its over 50GB) with just enough data to run reasonable integration tests over my project. Thanks for the response!
sdanna