Assert IEnumerables

I don't know which "standard .net test framework" you're referring to, but if it's Visual Studio Team System Unit testing stuff you could use CollectionAssert.

Your test would be like this:

CollectionAssert.AreEqual(ExpectedList, ActualList, "...");

Update: I forgot CollectionAssert needs an ICollection interface, so you'll have to call ActualList.ToList() to get it to compile. Returning the IEnumerable is a good thing, so don't change that just for the tests.


You want the SequenceEqual() extension method (LINQ):

    string[] x = { "abc", "def", "ghi" };
    List<string> y = new List<string>() { "abc", "def", "ghi" };

    bool isTrue = x.SequenceEqual(y);

or just:

   bool isTrue = x.SequenceEqual(new[] {"abc","def","ghi"});

(it will return false if they are different lengths, or any item is different)