During my code I communicate with a database (not a part of my solution file). The database is possessed with a separate team of DBA's, and also the code we designers write is just permitted to gain access to saved procs. However we've full look at the database's procs, tables, and posts (it's definition). For my code that's based mostly on data, I presently write unit tests that dumb-up data within the tables (and destroy/remove individuals rows following the unit test is performed), in order to run unit tests to exercise my code that interacts using the DB. All the code to get this done is incorporated in the test file (mainly in the ClassInitialize() and ClassCleanup() functions). However I have received some quantity of grief from the new colleagues call my type of unit tests "destructive" because I just readOrcreate towards the dev database placing and getting rid of rows. At that time we code the system tests, the database design is usually not stable, a lot of occasions we are able to find issues within the saved proc code before we release the QA department on our programs (saves assets). All of them let me know there's a method to clone towards the database into memory at that time the MSTest unit exams are run, however they do not know how to get it done. I have investigated online and can't try to do what my colleagues need me to complete.
Can someone let me know without a doubt whether it sometimes happens within the atmosphere I proven above? If that's the case, are you able to point me within the right direction?
If you're able to produce a 'seam' between your business logic code as well as your data access layer you ought to be ok. Use connects to represent anything your DAL exposes for your business logic after which either write your personal group of Fake objects or make use of a mocking tool for example rhino-mocks.
If you're writing tests that hit that database then you've an enormous maintenance headache, since while you condition, the database is altering, and it causes it to be hard to maintain an atmosphere that can access the database. What you're really writing are integration tests, that are still valid, but true unit test's shouldnt have dependencies on databases, file system, etc.