I got four queries, which are
1) Every table should have a clustered index
2) Every table should have a primary key
3) No tables should exist on the primary filegroup
4) Primary Keys should follow the naming standard, eg “pk_”
I already got the queries for these test conditions. Now i need to build a Visual Studio Database Project for unit testing in Visual Studio 2010 Ultimate. I get new databases coming in every now and then in my Sql Server Mgmt Studio 2008.
I need a suggestion on the best plan to implement so that I can create a unit testing template to test the above 4 test conditions for each new databases coming in. Is it a good idea to create a separate unit testing project for each test condition or should i create one unit testing project for all the conditions. Also Suggest me the best way to do it in Visual Studio 2010 Ultimate.
asked Mar 06 '11 at 09:02 PM in Default
Asking for "the best way" may lead to some discord, but here's a way which works, at least...
First, create a test project. In that test project, add a Database Unit Test.
After that, you will be able to add database tests. I would create four tests, one for each of your queries. These are simple enough that the Database Unit Test in VS2010 can work. More complex tests would probably require using something a bit stronger, like NUnit, but when I wrote the queries in my answer to your last question, I actually had this in mind.
You don't need to have different projects for each, nor do you even need a different test file. After you create them, the drop-down list shows each of your tests.
One advantage to doing it this way is that, in your Test View window, you can group by the class name and get all of your structural compliance tests together. Then, you could create, say, read-only tests, write-based tests, authorization/authentication tests, etc.
![Tests grouped by class name]
Once you get those in, you could copy the .cs and .resx files into other projects and they'll work there as well, so you get the benefits of a template. For that to work, you would need a DatabaseSetup.cs and an app.config, both of which are created automatically when a Database Unit Test is added to a test project. So you would be able to start working on your project-specific tests and drop these files in.: /upfiles/GroupedTests.png
answered Mar 07 '11 at 04:22 AM