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
I am trying to mock some old code and needs to mock bools and ints in some Natural mocking.

I see on you forum that mocking of mscorlib types has been requested a long time ago, but I don't see any followups. Any news on this issue ?

Regards
Jes Ramsing
asked by Larovia (3.8k points)

1 Answer

0 votes
Hi,

MSCorLib types are still not mockable. However, that means that you cannot mock methods on these types. If you are trying to return bools and ints from methods of all other types - you can do that of course.

For example, if you have a type ClassToIsolate which has a InstanceMethod that returns 3 as int, and you want to return 5 you can us this type of code:
   [Test]
   [VerifyMocks]
   public void TestWithNatural()
   {
     using (RecordExpectations recorder = RecorderManager.StartRecording()) 
     {
         ClassToIsolate mockedInstance = new ClassToIsolate();
         int i =  mockedInstance.InstanceMethod();
         recorder.Return(5);
     }            
   }


Please take a look at the examples at: https://www.typemock.com/Docs/HowTo.html

If you need some more help, please post your code and what you would like to mock, and we'll continue from there.
answered by gilz (14.5k points)
...