chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi

how can i mock an expection.
asked by (28.8k points)

2 Answers

0 votes
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.
answered by (6.7k points)
0 votes
silly of me :oops:

i do not know what i was thinking
answered by (28.8k points)
...