highlight test needs multiple projects loaded
I have a plugin with a highlighting that enumerates the projects within the solution - it looks for a matching class within another project based on the current class and the namespace of the project(s).
I have written some highlighting unit tests for the simple cases and taken a look the AgentMulder highlight unit tests (which aren't quite what I need) but can someone tell me how to load a solution or 2 projects into my resharper test to use so I can improve my test coverage?
Many thanks.
Please sign in to leave a comment.
As far as I can see, there isn't a good example of creating a solution with multiple projects, but it does look like it's supported. The BaseTestWithSolution abstract class gives you a solution that you can run your tests against. The derived (but still abstract) class BaseTestWithSingleProject uses the support in BaseTestWithSolution to create a solution with a single project. You can implement something similar, but create multiple projects.
The BaseTestWithSingleProject class has a method DoTestSolution, which is called from the main test entry points, such as DoOneTest and DoNamedTest (in other words, all tests go through this), and it calls CreateSolutionConfiguration, which in turn creates a new instance of TestSolutionConfiguration, passing in a single TestProjectConfiguration. You would need to create a class similar to BaseTestWithSingleProject, and instead of passing one instance of TestProjectConfiguration, you pass multiple, then you should get a solution with multiple projects. Passing this TestSolutionConfiguration to BaseTestWithSolution's DoTestSolution will cause the solution to be created, which in turn creates the child projects. Once the projects are created, it will try to wire up project-to-project references based on TestProjectConfiguration.ProjectNamesToRefer.
So, there isn't an off-the-shelf solution to this, but you can create one using the support in BaseTestWithSolution.
Thanks
Matt
Thank you Matt - I've got something working based on your advice. How do I post code into the forum?
Good stuff. As for adding code to the posts, copy and paste, attach the files or post a link to a gist...