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 have a static class that I have mocked a method on, and am also calling a method normally on. The called method goes along just fine until it hits a private member variable. Why are the rest of the methods and properties working fine, but not the member variables?

I have tried moving the instantiation of the vars to be at the declaration, and also inside the constructor. Again, everything here is static(if that makes any difference).

I have also tried debugging, but it appears that the mocks don't take effect when being debugged, because everything works like normal, and expectations don't get verified.

This is all in .net 2.0, vsnet2005, TypeMock 4.1.0 eval. Any help would be appreciated.

Thanks,
Steve
asked by vertebrate (1.8k points)

2 Answers

0 votes
Hi,

When you create a mock object, by default, the constructor of that instance is mocked and its real code is skipped. usually this means that most fields will not be initialized.

If possible, try using the Constructor.NotMocked statement when creating the mock. this will tell Typemock not to mock the constructor.
answered by lior (13.2k points)
0 votes
Thanks, that did the trick.
answered by vertebrate (1.8k points)
...