What do you mean by "mock an exception?"
If you want an exception to be thrown by a mocked call
, you can use the RecordExpectations.Throw or Mock.ExpectAndThrow methods (pending on whether you're using Natural or Reflective mocks, respectively). You can see an example of this on the How To page
under Section 3 ("Setting Expectations") in the item marked "Injecting Faults."
If you want to mock a value on an exception object
, like the Message property, it'd be just like any other object returning a fake value - RecordExpectations.Return or Mock.ExpectGet (for a property), for Natural or Reflective mocks, respectively.
If you would like to see some samples, you can either check out the How To page
or maybe post a little more detail about your question so we can get you a good and relevant example.