When asserting the content of collections, lists, dictionaries,… in unit tests, don’t do this:
Assert.That(this.result.Contains(this.expectedResult1)); Assert.That(this.result.Contains(this.expectedResult2));
Or this:
Assert.AreEqual(this.expectedResult1, this.result[0]); Assert.AreEqual(this.expectedResult2, this.result[1]);
What if you implemented your method wrong, and the result contains more than two elements? Unless you’re totally not interested in the size of the result, always check if the collection is as big as you expect it to be:
Assert.AreEqual(2, this.expectedResult.Count); Assert.AreEqual(this.expectedResult1, this.result[0]); Assert.AreEqual(this.expectedResult2, this.result[1]);