title: Fluent NHibernate PersistenceSpecification Component and Reference Tests
body: <p>I have two problems.</p>
  
  <p>1 . FNH does not test my component correcty and I dont know why.</p>
  
  <blockquote>
    <p>System.ApplicationException: Expected
    'DomainModel.Model.Publisher' but got
    'DomainModel.Model.Publisher' for
    Property 'Publisher'.</p>
  </blockquote>
  
  <pre><code>[TestMethod]
  public void CanCorrectlyMapBook()
  {
      new PersistenceSpecification&lt;Book&gt;(_session)
          .CheckProperty(p =&gt; p.Name, "My Book")
          .CheckProperty(p=&gt; p.Id, 1)
          .CheckProperty(p=&gt;p.IncludesCDDVD, true)
          .CheckProperty(p=&gt;p.Isbn, "rder93q43949éwr")
          .CheckProperty(p=&gt;p.IsLoaned, false)
          .CheckProperty(p=&gt;p.Publisher, new Publisher(){PublisherHomepage = "www.google.de", PublisherName = "google"})
          .VerifyTheMappings();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>2 . FNH does not test my reference correctly.</p>
  
  <blockquote>
    <p>System.ApplicationException: Expected
    'DomainModel.Model.Employee' but got
    'EmployeeProxyd6f94daa37c74be8b5ccccf40c5c23fa'
    for Property 'LoanedBy'.</p>
  </blockquote>
  
  <pre><code>[TestMethod]
  public void CanCorrectlyMapBook()
  {
      new PersistenceSpecification&lt;Book&gt;(_session)
          .CheckProperty(p =&gt; p.Name, "My Book")
          .CheckProperty(p=&gt; p.Id, 1)
          .CheckProperty(p=&gt;p.IncludesCDDVD, true)
          .CheckProperty(p=&gt;p.Isbn, "rder93q43949éwr")
          .CheckProperty(p=&gt;p.IsLoaned, false)
          .CheckReference(p=&gt;p.LoanedBy, new Employee(){EMail = "",FirstName = "Alex", LastName = "Mueller"})
          .VerifyTheMappings();
  }
  </code></pre>
  
  <p>But when I test this "manually" everything works fine.</p>
  
  <pre><code> ISession mysession = Helper.CreateSessionFactory(false, false).OpenSession();
              Book myBook = new Book()
                                {
                                    Author = "Hesse",
                                    IncludesCDDVD = true,
                                    DateOfIssue = DateTime.Now,
                                    Isbn = "erwe0ri",
                                    IsLoaned = true,
                                    Name = "My Book new",
                                    Publisher = new Publisher() { PublisherHomepage = "www.google.de", PublisherName = "google" },
                                    Release = new Release() { ReleaseDate = DateTime.Now, ReleaseNumber = 1 },
                                    LoanedBy = new Employee() { EMail = "", FirstName = "Alex", LastName = "Mueller" }
                                };
  
              mysession.Save(myBook);
              mysession.Close();
              mysession.Dispose();
  </code></pre>
  
  <p>I have verify this by looking up in the datbase ...</p>
  
  <p>The PersistenceSpecification Tests run against an in-memory database sqllite and my manual "test" runs against a Sql Server 2008.</p>
  
  <p>Does anybody of you have used FNH and tested a reference and a component correctly?</p>