Unit-testing IList with CollectionAssert

The MSTest structure has a CollectionAssert that accepts ICollections. My method returns an IList. The list does not appear to be a collection.

Are there any ways to make my IList ICollection?

+12
unit-testing mstest ilist icollection
Mar 19 '09 at 14:39
source share
2 answers

You can call the ToArray () extension method on it - the array implements ICollection

Edit: Also, while List<T> implements ICollection, IList<T> only implements ICollection<T> , which does not implement ICollection, so if you know that the item in the List<T> test, you should be able to fulfill it ...

+9
Mar 19 '09 at 14:43
source share

You can send a list

  List<string> actual = new List<string>(){"1","2","3"}; List<string> expected = new List<string>(){"1","2","**EditCaseFalse**"}; CollectionAssert.AreEqual(actual,expected) 

I return Failure (the third element does not match.)

+1
Apr 20 '09 at 18:27
source share



All Articles