I have the following interface method declaration:

public interface IFilter
{
  List<string> Filter (List<string> items);
}

And I want to create a mock filter object that:
- checks the argument, and then
- returns the argument passed to it.

var filterMock = MockRepository.GenerateMock<IFilter>();
filterMock
    .Expect (mock => mock.Filter(Arg<List<string>>.List.ContainsAll (...)))
    .Return (???);

Is there nothing I can pass as "???" to make the mock return the same
argument that was passed to it? Note that I don't want to set up a
"fake" result to return from the mock.

Things I've tried:
- "Do (mi => mi.ReturnValue = mi.Arguments[0])" to set the return
value; this doesn't work ("Method '...' requires a return value or an
exception to throw.").
- "Callback (...)", but this doesn't work together with the
constraints, so I have to do the argument checking by hand (which I
find isn't nice).
- "Arg.Matches (items => { storedItems = items; return items.Contains
(...); })", so that I could do "Return (storedItems)", but this
doesn't work as Arg.Matches requires a LINQ Expression, not simply a
delegate. And the assign statement cannot be transformed into an
Expression.

Any other ideas?

(This is Rhino Mocks RC 3.5.0.2. Telling me that newer versions have a
feature for this would also work :) )

Fabian

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" 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/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to