Alex Rivera | Logout

Why or how to use NUnit methods with ICollection<T>

Asked 2009-11-24T14:39:09.323
11

Some of NUnit's Assert methods are overloaded to use ICollection but not ICollection<T> and thus you can't use them.

Is there anyway around this? Heck, am I doing something stupid?

I'm having to drop back to using Assert.AreEqual rather than specialised methods and its making my tests ugly.

Any advice?

Edit:

Thanks for the responses. The That method of NUnit seems interesting so I'll look into it at a later date.

Mark correctly mentioned this, but NUnit Collection Asserts are excellent. I've recently used them on some new tests and found them excellent to work with.

Edit
Report

1 Answer

10

I don't know if this is what you're looking for, but for generic collections instead of using:

Assert.Contains(member, list);

I use:

Assert.That(list.Contains(member));

which I find almost as readable.

answered 2009-11-24T14:56:19.697

Your Answer