Hi
You can use the Mock.ExpectAndThrow method.
This will let throw any exception you want when your method is called.
public void Test()
{
Mock mock = MockManager.Mock(typeof(MyClass));
mock.ExpectAndThrow("somemethod", new CustomException("My message"));
try
{
MyClass.somemethod();
Assert.Fail("should have throw an exception");
}
catch (CustomException e)
{
Assert.AreEqual("My message", e.Message);
}
}
Note that if you are using natural mocks you should use
the RecordExpectations.ExpectAndThrow or RecordExpectations.Throw methods