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 new to TypeMock and I have been following the examples in the user manual for creating C# unit tests. I am trying to mock a static function
ClassFoo.Func1(int k)which returns an array of doubles.


double[] x = new double[]{2.45, 5.667};
int index = 567;
using (RecordExpectations recorder = RecorderManager.StartRecording() {

recorder.ExpectAndReturn(ClassFoo.Func1(index), x);

}

When I debug the test when the line "recorder.ExpectAndReturn(ClassFoo.Func1(index), x)" is executed, the execution goes into Func1 (which I am trying to mock) and throws an exception since the actual function has several uninitialized objects in it. Should I do something more to mock static functions ?

I am using TypeMock.NET version 4.1.00
asked by wavelet (600 points)

2 Answers

0 votes
Hi wavelet, and welcome to the wonderful world of Typemock!

First, I would suggest moving to a recent version. 5.3 is out and there's a lot that we added, fixed and made easier over time. The AAA syntax, for example makes tests much more easier to write.

As for your question, I need more input. Does the exception happen when you're not debugging as well? Please post the entire exception message, so we can investigate better.

Static methods are not different than instance methods for Isolator. You're using it correctly, so with your help, we can solve this quickly.

Thanks,
answered by gilz (14.5k points)
0 votes
Wavelet,

Is this still an issue, or did Gil's post point you in the right direction? Please let us know.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
...