title: Testing if a collection contains objects based on a particular property
body: <p>I'm using NUnit 2.5.7.  I want to test whether a collection of custom objects of a particular class contains certain objects, based on one of the class's properties.</p>
  
  <p>e.g. a contrived example...</p>
  
  <pre><code>public class Person
  {
      public string Name { get; set; }
  
      public Person(string name)
      {
          Name = name;
      }
  }
  
  // ...
  
  public List&lt;Person&gt; GetFavouritePeople()
  {
     List&lt;Person&gt; favouritePeople = new List&lt;Person&gt;();
     favouritePeople.Add(new Person("joe"));
     favouritePeople.Add(new Person("fred"));
     favouritePeople.Add(new Person("jenny"));
  
     return favouritePeople;
  }
  
  // ... 
  
  [Test]
  public GetFavouritePeople()
  {
      List&lt;Person&gt; people = GetFavouritePeople();
  
      // What I'd like to test, but not sure how to do it...
      Assert.Contains(Name="joe", people);
      Assert.Contains(Name="fred", people);
      Assert.Contains(Name="jenny", people);
  }
  </code></pre>
  
  <p>Although it would be simple enough in this example, I don't want to create mock objects for each Person and use those in the assertion... I just want to check based on a particular property (Name in this example.)</p>