dimanche 1 février 2015

Unit test the count in an IEnumerable

I am writing some unit tests for my MVC 5 internet application. I have a service class that returns the following:



IEnumerable<Account>


I am writing a unit test to check the number of items in the returned IEnumerable<Account>.


Because IEnumerable does not have a .Count() function, how should I check the number of items in the returned IEnumerable? Should I convert this IEnumerable to a List, and then do the Count? Is there a better way or more official way to do this?


Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire