Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit Assert a list of objects in no order

Tags:

nunit

How do I Assert a collection of items in no particular order? I just want to make sure all the items are in the list.

I'm heard of CollectionAssert but I do not see any method that would do what I want.

My object looks like this:

public class Vector2{
    public float X {get; set;}
    public float Y {get; set;}
}

Assert - I want something like this:

CollectionAssert.ContainsAll(mesh.GetPolygonVertices(0), aListOfVertices);

mesh.GetPolygonVertices(int) returns a List<Vector2> and aListOfVertices contains all of what is returned, but not guaranteed that order.

like image 855
Shawn Mclean Avatar asked Dec 25 '10 19:12

Shawn Mclean


1 Answers

The AreEqual overloads succeed if two collections contain the same objects in the same order. AreEquivalent tests whether collections contain the same objects regardless of their order.

http://www.nunit.org/index.php?p=collectionAssert&r=2.4

like image 80
Jahan Zinedine Avatar answered Nov 11 '22 15:11

Jahan Zinedine