|
From: Joe R. <joe...@gm...> - 2006-03-01 19:14:59
|
Mike-
I'm not involved in the development of NMock2 obviously, but the
question I raise is whether or not everyone's definition of two lists
being equal is the same. My definition for my purpose was that each
list contained the same items in the same order. Someone else might
only care about the same items being in each list but not necessarily
the same order. I realize there is also a SortedList<T> in .NET 2.0,
but I want to use List<T> and add the objects in the correct order
based on business logic
Are there other complexities to two lists being equal that I'm not
considering? My implementation was is simple as a null check, a count
check, then an object comparison across the lists.
-joe
On 3/1/06, Mike Mason <mik...@gm...> wrote:
> On 2/23/06, Nat Pryce <nat...@gm...> wrote:
> > 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.
> > 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))=
;
> >
>
> We had the same problem on our projects and I created a ComparableList<T>
> class that overrode equals and did the right thing, but the matcher looks
> much more like it's the right thing to do.
>
> Is this something we should implement directly in NMock2 instead of
> requiring folks to implement their own ListEqualTo() matcher?
>
> Cheers,
> Mike.
>
|