Wrap it with another class implementing an interface. When unit testing inject the mock implementation.
public interface IExceptionManager
{
event DispatcherUnhandledExceptionEventHandler DispatcherUnhandledException;
}
public class ExceptionManager : IExceptionManager
{
Application _app;
public ExceptionManager(Application app)
{
_app = app;
}
public event DispatcherUnhandledExceptionEventHandler DispatcherUnhandledException
{
add
{
_app.DispatcherUnhandledException += value;
}
remove
{
_app.DispatcherUnhandledException -= value;
}
}
}
public class MockExceptionManager: IExceptionManager
{
public event DispatcherUnhandledExceptionEventHandler DispatcherUnhandledException;
}