Testing event handling in an MS Office add-in

Niklas Deutschmann <[email protected]> Fri, 08 Aug 2008 09:46:12 +0200
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Hi,

I'm just trying to test some event handlers in a VSTO add-in for Visio 2007.

In the method that is annotated with "TestFixtureSetUp", I launch an 
instance of Visio:

Visio.Application app = new Visio.Application();

In the method annotated with "TestFixtureTearDown", I shut down the 
running Visio instance:

app.Quit();

In the test methods, I create a diagram and manipulate it using the 
Visio Automation API. I expect the diagram actions to trigger the event 
handlers that are registered in the startup method of the add-in. But 
there seems to be no event handling at all, and in the NUnit's "Trace" 
window, I don't even see any of my log messages that show that the 
add-in is loaded.

However, when I remove the tear-down method, the Visio instance remains 
open, I can work with the add-in without any error, and  Visio is 
showing it as "loaded". So, the add-in seems to be inactive only from 
the perspective of NUnit. Is this caused by the different AppDomains
for the add-in DLLs in the test (that are loaded by NUnit) and the 
running Visio instance (that may load a different copy of the add-in 
DLLs)? How can I get Visio's event loop (I think this even applies to 
other Office applications) "inside" the test?

Regards,
Niklas

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/