Testing if a collection contains objects based on a particular property
You could use LINQ: Assert.That(people.Any(p => p.Name == “joe”)); or, if you want to be explicit about there being exactly one person with each name: Assert.That(people.Count(p => p.Name == “joe”), Is.EqualTo(1)); If you want a better error message than “Assertion failed, expected true, was false”, you could create your own assert method. For several collection-related … Read more