You can use the "Do" extension for Rhino.Mocks to create a specific exception:
public delegate void ThrowExceptionDelegate();
mystub.Stub(x => x.ReadFile()).Do(new ThrowExceptionDelegate(delegate()
{ throw new IOException(); }
));
This will allow you to test the exception handling code.
source
share