Arg was implemented to be a full replacement for - IgnoreArguments - Constraints - OutRef
Arg syntax also specifies the type of the argument, null does not, this is another benefit. Sometimes, it is important to specify the type of the argument, to make clear which overloaded method should be used. Example: foo(object o) foo(string s) foo(IEnumerable e) // which foo should be called? m.AssertWasCalled(x => x.foo(null), o => o.IgnoreArguments()) // workaround, casting the null, not obvious m.AssertWasCalled(x => x.foo((string)null), o => o.IgnoreArguments()) // using Arg, idiot proof m.AssertWasCalled(x => x.foo(Arg<string>.Is.Anything)) On 12 Jul., 05:02, Chris Missal <[email protected]> wrote: > Got it! Thanks for the distinction. > > > > On Sat, Jul 11, 2009 at 7:09 PM, Kenneth Xu <[email protected]> wrote: > > > Chris, > > > They are identical. Later was newly introduced and more flexible then > > former. For example, > > > m.AsssertWasCalled(x=>x.Foo(Arg<int>.Is.Anthing, Arg<string>.Is.NotNull)); > > > Which cannot be expressed by the former syntax. > > > HTH > > > Kenneth > > > On Fri, Jul 10, 2009 at 11:14 PM, Chris Missal<[email protected]> > > wrote: > > > What's the difference between the following: > > > > mockSessionRepository.AssertWasCalled(x => x.GetSessions(null), y => > > > y.IgnoreArguments()); > > > > and > > > > mockSessionRepository.AssertWasCalled(x => > > > x.GetSessions(Arg<Criteria>.Is.Anything))); > > > > Is the only difference that one one asserts not null versus null? (or is > > > that not even correct...) What's a good example of when to use one > > instead > > > of another? > > > > -- > > > Chris Missal > > >http://chrismissal.lostechies.com/ > > -- > Chris Missalhttp://chrismissal.lostechies.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
