I am currently writing a C# project and I need to do unit testing for the project. For one of the methods that I need to unit test I make use of an ICollection which is normally populated from the selected items of a list box.
When I create a unit test for the method it creates the line
ICollection icollection = null; //Initialise to an appropriate value
How can I create an instance of this ICollection and an item to the collection?
ICollectionis an interface, you can’t instantiate it directly. You’ll need to instantiate a class that implementsICollection; for example,List<T>. Also, theICollectioninterface doesn’t have anAddmethod — you’ll need something that implementsIListorIList<T>for that.Example: