That is the way to do this.

On Wed, Mar 24, 2010 at 7:27 PM, Bill Pierce <[email protected]> wrote:

> I have an interface:
>
> interface IFoo
> {
>   IBar CreateNew();
> }
>
> In my tests I have:
>
> var foo = MockRepository.GenerateMock<IFoo>();
>
> foo
>   .Expect(x => x.CreateNew())
>   .Return(MockRepository.GenerateMock<IBar>());
>
> I would like foo.CreateNew() to always return a new mock instance.
> Currently it returns the same mocked instance on each call.  What is the
> best way to achieve this?  This appears to work but feels wrong:
>
> foo
>   .Expect(x => x.CreateNew())
>   .WhenCalled(x => x.ReturnValue = MockRepository.GenerateMock<IBar>());
>
> Thanks,
> -Bill
>
> --
> You received this message because you are subscribed to the Google Groups
> "Rhino Tools Dev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rhino-tools-dev%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhino-tools-dev?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en.

Reply via email to