int[] expected = { 1, 2, 3 }; int[] actual = { 3, 2, 1 }; Assert.AreElementsEqualIgnoringOrder(expected, actual);
ListThis test will also pass because both lists have the same elements, just in a different order. The Assert.AreElementsEqualIgnoringOrder method is part of the Microsoft.VisualStudio.TestTools.UnitTesting package, which is included in the Microsoft.NET.Test.Sdk package.expected = new List () { "apple", "banana", "cherry" }; List actual = new List () { "banana", "apple", "cherry" }; Assert.AreElementsEqualIgnoringOrder(expected, actual);