I wrote a small helper method contentsToArrayList. If I pass it an object which implements ICollection, it returns an ArrayList containing the same elements as the original object. If I pass it another object, it returns an ArrayList containing the object itself.
Now I want to test the method. My unit test looks like this (a bit abbreviated, I included more test cases):
//Arrange
int a = 1;
ArrayList aAsArrayList = new ArrayList();
aAsArrayList.Add(a);
List<int> f = new List<int>() { 4, 5, 6 };
ArrayList fAsArrayList = new ArrayList(f);
//Act
ArrayList aReturned = contentsToArrayList(a);
ArrayList fReturned = contentsToArrayList(f);
Now I am not sure how to write my asserts. Basically, I want to make sure that aAsArrayList contains the same object(s) as aReturned. But ArrayList being a reference type, I am not sure it has value equality defined. Can I just compare the arraylists easily, using something like aReturned == aAsArrayList, or do I have to compare each member of the arraylist?