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.
ICollectionandICollection<T>are different contracts – one does not inherit the other.http://msdn.microsoft.com/en-us/library/system.collections.icollection_members.aspx
http://msdn.microsoft.com/en-us/library/y2fx0ty0.aspx
If you have a generic collection you can call
ToList()on it and get aList<T>, which happens to implement the non-genericICollectionas well. Then use that List in the NUnit Assert method.