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 All,
i have seen various method calls where we actually return a value

int method(int takethecount)
{
return 5;
}


Can somebody help me out how would i approach this kind of methods

MyResource method(int intMymockvalue)
{
return Myresource
}

How do i mock the Return Value


thanks in advance

thomson
asked by tomexplore (1.8k points)

2 Answers

0 votes
Hi,

In general mocking is done the same for all methods.
try looking at our how to's page to see several simples cases on mock usage.

heres an example for you case:
MyResource fake = new MyResource();
using (RecordExpectations rec = new RecordExpectations()
{
  MethodClass mock = new methodClass();
  mock.method(0);
  rec.Return(fake);
}


where MethodClass is the class in which method is declared in.

:!: Please try to be more specific in the future. It kind of hard to build understandable examples from your pieces of code. Best will be if you can just paste in code taken from a real test in which you show what you are trying to do.
answered by lior (13.2k points)
0 votes
Thanks mate , i will give specific example in the future
answered by tomexplore (1.8k points)
...