0

I'm pretty new to unit-testing. I hope I can get some ideas from you guys how I can solve my "problems".

Here is what I want to do:

We have some SQL Server 2012 databases. For unit-testing in Visual Studio 2012, I want to programmatically create a LocalDB which has the same tables / functions / procedures like the "normal" databases.

But the tables in the LocalDB should be empty and be populated with data (only the data needed for the test) in the unit-tests (so after every test the LocalDB is empty)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
WhoisIt
  • 123
  • 2
  • 10
  • 1
    whats the question? you should probably use something like dbup (http://dbup.github.io/) to create your database in LocalDB (this is not its only purpose - its purpose is for the migration of data as your app changes however it is very useful for unit testing purposes too) – wal Jun 09 '14 at 07:24

1 Answers1

1

Have a look at http://dbsourcetools.codeplex.com/
It is designed for this purpose - to re-create an instance of a database locally.
Just point it to your 2012 databases, and it will script the entire database schema to disk. You can then use it to run these scripts in the correct order to re-create the database. You can also select which data from which tables to include ( config data ).

blorkfish
  • 21,800
  • 4
  • 33
  • 24