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
0 votes
Hi everyone

I'm trying to ensure that a test will fail when a certain method is called. I have something like this:

using (RecordExpectations recorder = RecorderManager.StartRecording())
{
myClass.DoNotCallThisMethod();
recorder.FailWhenCalled();
}

When I run the test, I get a VerifyException saying the method has one more expected call. My question is, is my DoNotCallThisMethod() still being expected to be called when using recorder.FailWhenCalled()?

Thanks,
Jonathan Khor
asked by Jonathan Khor (1.1k points)

3 Answers

0 votes
Hi Jonathan

You are right FailWhenCalled don't behave as one would expect from its name.
We will fix it and send you the patch.
Meanwhile you can use this workaround:
            using (RecordExpectations r = RecorderManager.StartRecording())
            {               
                myClass.DoNotCallThisMethod();                
                recorder.FailWhenCalled().RepeatAlways();
            }
answered by ohad (35.4k points)
0 votes
Hi Jonathan
The patch was created and sent.
Please tell me if it solves the problem.
answered by ohad (35.4k points)
0 votes
Hi Ohad

Thanks for the quick reply! Initial tests shows the fix works just fine. It's a pleasure developing with TypeMock :D
answered by Jonathan Khor (1.1k points)
...