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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
Hi,

I'm having some trouble getting the Throw methods to work for me. The following code doesn't work for me.

MockObject mockReader = MockManager.MockObject<IDataReader>();
mockReader.AlwaysThrow("GetOrdinal", new IndexOutOfRangeException());


And I get the following error message:

Test method ConstructTestIndexOutOfRangeException threw exception TypeMock.TypeMockException, but exception System.IndexOutOfRangeException was expected. Exception message: TypeMock.TypeMockException:
*** No method GetOrdinal in type System.Data.IDataReader


But when I run the code below it work fine for me.

MockObject mockReader = MockManager.MockObject<IDataReader>();
mockReader.ExpectAndReturn("GetOrdinal", 1);


What's the difference? Both are calling the same method. How to I get the AlwaysThrow code to work?

Thanks,
Eric[/quote]
asked by (3.8k points)

1 Answer

0 votes
Eric,
This has been fixed in version 4.0.2 that is out just an hour ago.
Please Download and Install to fix the problem
answered by (32k points)
...