In your case, you want to write an integration test to cover the scenario you described. I have a complete entry in this section . However, here is a generalized version specific to your question:
In his book, The Art of Unit Testing, Roy Osherow describes the key principle that unit test should be "trustworthy." At first glance, this seems pretty obvious. However, this is based on the main differences between the unit test and the integration test.
With a reliable test, you should be able to trust the results in 100% of cases. If the test fails, you must be sure that the code is broken and needs to be fixed. You do not need to ask such things as βWas the database inaccessible?β, βWas the connection string OK?β, βWas the stored procedure changed?β. Asking these questions, he shows that you cannot trust the results, and you probably have a poorly designed "unit test".
As your scenario describes a situation with similar multiple dependencies, you want to cover it with an integration test. Again, for more information, see my full post here .
Good luck
Chris melinn
source share