Per the subject, I'm testing some WCF-related code and trying to setup an exceptional case:
Isolate.SwapNextInstance<AutofacServiceHost>().With(autofacHost);
Isolate.WhenCalled(() => autofacHost.Open()).IgnoreCall();
Isolate.WhenCalled(() => autofacHost.Close()).WillThrow(new TimeoutException());
The code under test:
try
{
serviceHost.Close();
}
catch (CommunicationObjectFaultedException)
{
}
catch (TimeoutException)
{
}
The exception is thrown, but if I step through it in the debugger the type of the exception object is System.MulticastDelegate, not System.TimeoutException. Very bizarre...
If you change the above isolation to simulate a CommunicationObjectFaultedException, everything works as expected.
Any thoughts?
Thanks,
Matt