Home > Archive > Extreme Programming > June 2005 > NMOCK
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| mgwalm@gmail.com 2005-05-19, 3:58 am |
| Im having problems using nmock.
1) i have a function declared as public void Clear(). I cant seem to
call SetUpResult with this type of function, as it (SetUpResult)
expects a return type and and an array of parameter types. In this case
they are all void. Everything ive tried eg using null or an empty array
causes nmock to raise an exception.
2) if i could find any docs re nmock i could probally read about a
solution, but cant find anything reasonable anywhere. So a link to some
real docs would be appreciated.
Regards
Michael
| |
| KageVF 2005-05-24, 8:56 pm |
| Michael,
1) For a function that doesn't have a return value try using
Type.EmptyTypes. That's VB.NET syntax, so there might be a different
way to express that in C#.
2) Best resource I know of is the MSDN article on NMock at
http://msdn.microsoft.com/msdnmag/i...k/default.aspx. It's
not actual "documentation" but it looks like that's all we have . . .
mgwalm@gmail.com wrote:
> Im having problems using nmock.
>
> 1) i have a function declared as public void Clear(). I cant seem to
> call SetUpResult with this type of function, as it (SetUpResult)
> expects a return type and and an array of parameter types. In this case
> they are all void. Everything ive tried eg using null or an empty array
> causes nmock to raise an exception.
>
> 2) if i could find any docs re nmock i could probally read about a
> solution, but cant find anything reasonable anywhere. So a link to some
> real docs would be appreciated.
>
> Regards
> Michael
| |
| jeem.hughes@gmail.com 2005-06-08, 3:58 pm |
|
mgwalm@gmail.com wrote:
> Im having problems using nmock.
>
> 1) i have a function declared as public void Clear(). I cant seem to
> call SetUpResult with this type of function, as it (SetUpResult)
> expects a return type and and an array of parameter types. In this case
> they are all void. Everything ive tried eg using null or an empty array
> causes nmock to raise an exception.
>
> 2) if i could find any docs re nmock i could probally read about a
> solution, but cant find anything reasonable anywhere. So a link to some
> real docs would be appreciated.
>
> Regards
> Michael
You shouldn't call SetUpResult for a method with no return value.
SetUpResult says, "this method may be called once or a zillion times or
not at all. if anyone calls it, return this value." If you want to
make sure Clear is called, use Expect. If you don't call Expect and
the code does call Clear, I think that will be fine; it'll just no-op.
Jim
|
|
|
|
|