When this presents itself what I do is is the following:
- Create a new folder in Visual Studio named the same as your namespace
- Extract the tests from the class file into another class file.
- Name the new class file the same as the test name
- Inherit from the base class file (ie the class file we removed the tests from)
- Create a virtual void method in the base class named observe()
- Call the virtual method at the end of the Setup method in the base class
- Create an override method in the sub-class to set the conditions that would exercise the expected behavior
- Name the new Test method in the sub-class execute()
- Place all class files into the new folder
The downside of this approach is that you end up with quite a few test class files because you end up with one test per class. I am ok with this because I can look at my test names and easily determine what they are visually in Visual Studio.
The upside is I can easily group me tests together and reuse setup code across multiple tests.