VSTO Unit Testing

E

Enrique

Question

I am posting this question again (3rd time) because some issues with my no
spam alias.
Here it is the question:


I have not been able to run unit tests for a VSTO (2005) project. I have an
Excel project and a unit test project in the same solution. I have not found
the way to initialize the runtimecallback as required by the code generated
by visual studio (see statement below). I relay heavily on unit testing and
having this working is a must. I hope I am missing something obvious here.
Please help.

'code generated by visual studio
Dim RuntimeCallback As
Global.Microsoft.VisualStudio.Tools.Applications.Runtime.IRuntimeServiceProvider = Nothing 'TODO: Initialize to an appropriate value
 
L

Luke Zhang [MSFT]

Hello,

In a Unit Test project, we can simple create a class inplementing the
interface 'IRuntimeServiceProvider', and Initialize a object from this
class here. For example:
add a class to the Test project:


Public Class Class1
Implements
Microsoft.VisualStudio.Tools.Applications.Runtime.IRuntimeServiceProvider


Public Function GetService(ByVal serviceType As System.Type) As Object
Implements
Microsoft.VisualStudio.Tools.Applications.Runtime.IRuntimeServiceProvider.Ge
tService
Return Nothing
End Function

End Class

and change following line:

Dim RuntimeCallback As
Global.Microsoft.VisualStudio.Tools.Applications.Runtime.IRuntimeServiceProv
ider = Nothing 'TODO: Initialize to an appropriate value


to:

Dim RuntimeCallback As IRuntimeServiceProvider = New Class1()

If there is any further questions, please feel free to let us know

Luke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top