I use Constraints (your first option), the new inline constraints
http://ayende.com/Wiki/Rhino+Mocks+3.5.ashx#Inlineconstraints gives a pretty
good syntax I think.

I prefer Is.Anything() to refering to an argument to ignore by index; it
would seem a bit unmaintainable to use an index.

Regards
Alex

On Wed, Apr 1, 2009 at 2:23 PM, Koen Verheyen <verheyen.k...@gmail.com>wrote:

>
> Hi Ayende,
>
> Dunno if I’m asking for a bit of support here or a feature request.
>
> What I wanna do a lot with Rhino Mocks is the following: I set an
> expectation on a dependency (dynamic mock) on a method that takes
> parameters, but I have a lot of cases where I don’t know one of the
> parameters (usually a reference that is created in the scope of the
> public method I’m testing).
>
> I found two ways of doing this, with “Constraints” and “WhenCalled”:
> swimlaneRepository.Expect(r => r.QuerySwimlanesToRemove(Guid.Empty,
> null)).Constraints(Is.Equal(processDefinitionId), Is.Anything());
>
> swimlaneRepository.Expect(r => r.QuerySwimlanesToRemove(Guid.Empty,
> null)).IgnoreArguments().WhenCalled(
>    mo =>
>    {
>        Assert.AreEqual(processDefinitionId, mo.Arguments[0]);
>    });
>
> … but would like to write it more or less, like this:
>
> swimlaneRepository.Expect(r => r.QuerySwimlanesToRemove
> (processDefinitionId, null)).IgnoreArguments(1);
>
> ... where “1” points to the second parameter and ignoring only that
> one, but still expecting the value of the first parameter (index 0).
> The argument of “IgnoreArguments” would thus be “params int[]”
>
> Is there already something like this in Rhino mocks? If not, I think
> it’d be a nice feature request (if technically possible)...
>
> Thanks
>
> Koen
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to RhinoMocks@googlegroups.com
To unsubscribe from this group, send email to 
rhinomocks+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to