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 want to have one of my mocked methods take N seconds to return. This is so I can test how the system handles such latency. Is there a way TypeMock can do this?
asked by rileytaylor (3.2k points)

1 Answer

0 votes
Here is one way using DynamicReturnValues.
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
   TestedClass.LongMethod();
   recorder.Return(new DynamicReturnValue(WaitALongTime));
}

private object WaitALongTime(object[] p,object context) 
{
   System.Threading.Thread.Sleep(5000);
   return null;
}


Note: You can use MockManager.CONTINUE_WITH_METHOD to call original method
answered by scott (32k points)
...