|
From: Nat P. <nat...@gm...> - 2006-02-23 12:52:43
|
You need to pass a custom matcher to the With method, since you want
to match on a single argument.
E.g. create a EqualListsMatcher that checks if two lists are equal.=20
Write a convenient factory function to create it, then use it in an
expectation like:
On(mock).Method("Foo").With(ListEqualTo(someList)).Will(Return.Value(10=
));
--Nat.
On 2/22/06, Joe Ross <joe...@gm...> wrote:
> I believe you can disregard this question. Since sending the email
> I've discovered that I can pass a Matcher to the "To" method in
> addition to a value. This seems to accomplish what I'm after. I was
> trying to do .To (value).Matching (myMatcher) which I now know to be
> incorrect.
>
> If there's a better way to do this, I'd still like to hear any advice.
>
> Thanks!
> -joe
>
> On 2/22/06, Joe Ross <joe...@gm...> wrote:
> > I've done all of the due diligence I could think of before asking this
> > question. It seems obvious and I found some references to it on a
> > JMock forum but nothing with regards to NMock. I did most of my
> > searching with regards to ArrayLists as I figured there would be more
> > posts about .NET 1.x than 2.x.
> >
> > So anyway, the question is: I have an interface that exposes a
> > property of type List<T>. I've worked my way through the NMock2
> > source and discovered that when calling the setter, an
> > NMock2.Matchers.EqualMatcher is used to determine if the value passed
> > to the setter matches the expectation. EqualMatcher checks if it's an
> > array by using "is Array" (it is not technically an array) so then it
> > does an equals. At this point it's basically comparing the addresses
> > that each reference is pointing two. The addresses are different so
> > it fails.
> >
> > I need a more complex check than this for this collection. I thought
> > I could create a custom Matcher but it appears that the
> > ArgumentsMatcher is called before ExtraMatchersMatch. Is there a way
> > to override which ArgumentsMatcher is used?
> >
> > Again, I apologize if this question has been covered before. I
> > searched Google and this mailing list. I made my way through the
> > source code. I don't really know of a good source of NMock2
> > documentation (I have that cheat sheet PDF which is nice) besides the
> > source code and tests.
> >
> > Thanks for any assistance to an NMock2 newcomer,
> > -joe
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi=
les
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmdlnk&kid=103432&bid#0486&dat=121642
> _______________________________________________
> NMock-two-dev mailing list
> NMo...@li...
> https://lists.sourceforge.net/lists/listinfo/nmock-two-dev
>
|