Convert IOccurence to UnitTestElement?

I am successfully using the 5.x R# API in VS 2008 to recursively walk the usages chain of the selected element and find all of the methods that are decorated with NUnit test attributes.  The goal here is to add a RunUnitTestBulbItem menu to classes, methods & properties that I can use to create a UnitTestManagerImpl, populate it with all of the NUnit.Framework.TestAttribute methods found in the usage chain.  That way, when a developer modifies a class or method, they can easily run any unit tests that would exercise their code right away.

So far, after my search is complete, I end up with an IEnumerable<IOccurence>.  My sticking point right now is that I need to convert this into either an IEnumerable<TreeModelViewNode> or an IEnumerable<UnitTestElement> - whichever is easier.  The reason is that I need to pass this into the UnitTestManagerImpl like so:

IEnumerable<IOccurence> results = GetUsages(IDeclaredElement selectedElement);

UnitTestManagerImpl mgr = new UnitTestManagerImpl(DataProvider.Solution);

mgr.OpenSession(mgr.CreateSession( /* IEnumerable of results cast to appropriate type */ ));

Does anyone have any advise on how I can make this jump from the search results to the test session?

Thanks in advance ...


Please sign in to leave a comment.