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 like to keep my tests as much unitary as possible.

So, when I have something like this:

public void Method()
{
  Method(default);
}


I would like to test it like this:

using (RecordExpectations recorder = RecorderManager.StartRecording())
{
  Method(default);
  recorder.CheckArguments(default);
}
Method();


But TypeMock complains that I'm calling method with no arguments and it's expecting one.

I usually solve this problem with something like this:

using (RecordExpectations recorder = RecorderManager.StartRecording())
{
  Method();
  recorder.CheckArguments();

  Method(default);
  recorder.CheckArguments(default);
}
Method();


Is this the only way?
asked by paulo.morgado (11k points)

2 Answers

0 votes
Paulo hi,

We have a known issue with oveload methods. It causes typemock to confuse them resulting in what you are experiencing, currently this is the only way to bypass the problem.

we are wortking on solving the issue and hopefully in will be resolved in our next release.

btw It think that the you would want to have your test look like:
            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                Method();
                recorder.CallOriginal();

                Method(5);
                recorder.CheckArguments(5);
            }
            Method();
            MockManager.Verify();
answered by lior (13.2k points)
0 votes
Thanks, Lior, I'll be waiting.

I actually meant:

using (RecordExpectations recorder = RecorderManager.StartRecording()) 
{ 
  Method(); 
  recorder.CheckArguments(); 
  recorder.CallOriginal();

  Method(default); 
  recorder.CheckArguments(default); 
} 
Method();
answered by paulo.morgado (11k points)
...