Visualize/list/check dependencies I have to mock in unit test?
Given a unit test for old, hard-to-read C# legacy code, what are the best ways to:
- find the dependencies (visualize them, or outoput a list for a single method)
- check after refactoring that all dependencies got broken, that the unit test is really isolated. No hidden invocation of DateTime.Now, no Database/File/Service access, no calls to anything which is not a stub or mock (other than some trusted .NET framework stuff, etc.)
Most probably a question about tooling.
I could manually look through the code and assume I didn't forget to break all dependencies, but that's error-prone. The thing I do right now is marking (via some hidden resharper feature) all usings of certain (non-interface-only, custom) namespaces. But there are assemblies which mix interfaces and implementations, plus n开发者_StackOverflowot all of my coworkers use Resharper, plus I have the gut feeling it could be even easier, e.g. simple yes/no check.
If tehre is some great commercial tool for that, that's fine, too.
EDIT: maybe I should expresse it in a cleaner way: how can I easily, within Visual Studio, see what non-interface dependencies my class/method depends on? There gotta be tools for that (I hope), money is a secondary concern.
My answer may not be of any use for you anymore, given that the question was asked a long time ago, but in case anyone else has a similar problem to solve:
http://msdn.microsoft.com/en-us/magazine/cc163641.aspx
精彩评论