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
Is it in TypeMock somthing analogous to "Do" steatment in rhino mock?
The scenario i want to realise is as fallowing:
I have in outer file a large set of data in the form of pairs ( input param, calculed ret val ) . I can write somthing like this:

for( i = 0 ; i < size ; i++ )
{
     myObject.f( a[i] ) ;
     recorder.Return( b[i] ).RepeatAlways().WhenArgumentsMatch() ;
}


but what if the size if really very big? I would preffer direct access to the item in data file.
Thanks for help.
asked by Lukasz Czekaj (1.2k points)

2 Answers

0 votes
I am not sure what to Do statement is.
There are a few ways to deal with this.
1. create a fake file with your data and mock the Load statement to read the test file
// in your code:
Load("data.txt");
// to mock:
mock.Exepect("Load").Args(new Assert(@"....	est.txt"));


2. You can return a new HashTable and return it instead of your file implementation:
recorder.ExpectAndReturn(myObject.f, new Hashtable());


3. Use DynamicReturnValues
myObject.f();
recorder.Return(new DynamicReturnValue(
  delegate(object[] p, object c) 
  { 
     int index = int(p[0]);
     return b(index); 
  }));
answered by scott (32k points)
0 votes
DynamicReturnValues - that is what i need. Thanks.
answered by Lukasz Czekaj (1.2k points)
...