title: How to test fluent-NHibernate's PersistenceSpecification.VerifyTheMappings with lists and relational objects?
body: <p>How would you test this scenario?</p>
  
  <p>I've just started looking into NHibernate and having my first bash at TDD. So far I've really enjoyed it and have been using fluent-Nhibernate for my mapping of the classes.</p>
  
  <p>However I seem to be hitting a dead end when it comes to using the VerifyTheMappings method on PersistenceSpecification.</p>
  
  <p>Essentially I have two classes, Recipient and RecipientList. The RecipientList class has a mapping to the Recipient with a fluent "HasMany" relationship:</p>
  
  <pre><code>public class RecipientListMap : ClassMap&lt;RecipientList&gt;
  {
  
      public RecipientListMap()
      {
          Id(x =&gt; x.ID);
          Map(x =&gt; x.ApplicationID);
          Map(x =&gt; x.Name);
          Map(x =&gt; x.IsDeleted);
          HasMany&lt;Recipient&gt;(x =&gt; x.Recipients).WithKeyColumn("RecipientListID").AsList().LazyLoad();
      }
  
  }
  </code></pre>
  
  <p>However when I use the following code in my test:</p>
  
  <pre><code>private IList&lt;Recipient&gt; _recipients = new List&lt;Recipient&gt;()
          {
              new Recipient { FirstName = "Joe", LastName = "Bloggs", Email = "joe@bloggs.com", IsDeleted = false },
              new Recipient { FirstName = "John", LastName = "Doe", Email = "john@doe.com", IsDeleted = false },
              new Recipient { FirstName = "Jane", LastName = "Smith", Email = "john@smith.com", IsDeleted = false }
          };
  
          [Test]
          public void Can_Add_RecipientList_To_Database()
          {
              new PersistenceSpecification&lt;RecipientList&gt;(Session)
                  .CheckProperty(x =&gt; x.Name, "My List")
                  .CheckProperty(x =&gt; x.Columns, "My columns")
                  .CheckProperty(x =&gt; x.IsDeleted, false)
                  .CheckProperty(x =&gt; x.ApplicationID, Guid.NewGuid())
                  .CheckProperty(x =&gt; x.Recipients, _recipients)
                  .VerifyTheMappings();
          }
  </code></pre>
  
  <p>The following error occurs:</p>
  
  <pre><code>failed: System.ApplicationException : Expected 'System.Collections.Generic.List`1[Project.Data.Domains.Recipients.Recipient]' but got 'NHibernate.Collection.Generic.PersistentGenericBag`1[Project.Data.Domains.Recipients.Recipient]' for Property 'Recipients'
  </code></pre>
  
  <p>I can see that the error is because I am passing in a List and the list returned is a PersistentGenericBag, therefore throwing an error. I don't get how you are suppose test this though if you can't just pass in an IList?</p>
  
  <p>Any help would be appreciated.</p>