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
If I set up a Mock using Natural or reflective and then specify which methods are to be called using ExpectAndReturn or in the using RecordExpectations block, is the order of these calls recorded? It seems not or at least not if I expect the same method more than once with different arguments each time.

I'd prefer to do it with Reflective Mocks.

Thanks.
asked by RAD (1.8k points)

3 Answers

0 votes
Hi,

We are currently not supporting ordered calls. That is to say, when doing verification, we verify that all the expected calls were actually made, but we do not verify their order. In addition, once the recording is done, and a call is made, we check if there's an expectation on it. The call could be made either first or third, but Typemock does not store this information and therefore cannot verify it.

Can you post some code where and how you would use it? (You can invent your own API here :) ). I would also like to get people's opinions on it.
answered by gilz (14.5k points)
0 votes
Thanks for quick response.

It may not be a big issue for us - I am still in investigating TypeMock

I have sort of achieved it with recorder...

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {        
                recorder.MockAllInstances = true;
                MockedClass mockedClass = new MockedClass ();
                recorder.DefaultBehavior.CheckArguments(); // <-- Need this to check order of calls
                mockedClass.Method("firstTimeParam");

                mockedClass.Method("secondTimeParam");
            }


but this is only in the case where the same method is called on the same object and of course where there are areguments to check.

I expect there are ways to achieve this using my own code.

I can imagine though that checking the order would be useful - and useful to switch off.
answered by RAD (1.8k points)
0 votes
Hi,

Like you say, in the simple case, it is possible, but if want to take it a bit further, there a some very interesting situations that today, can confuse the verifier. So please proceed with caution.

This kind of feature is already on our wish list, and we'll get it inside the software in some future version.
answered by gilz (14.5k points)
...