title: Fluent nHibernate Unit Test HasOne mapping
body: <p>I have situation where I DO require one-to-one relationship thus the usage of <code>HasOne</code>. Yes I do want to have separate table for <code>Patrons</code> and <code>Members</code>. Following are my classes and their corresponding mapping classes.</p>
  
  <pre><code>public class Member
  {
      public virtual string ID { get; set; }
      public virtual bool IsRegistered { get; set; }
      public virtual Patron Patron { get; set; }
      public virtual string Reference1 { get; set; }
      public virtual string Reference2 { get; set; }        
  }
  
  public class Patron
  {
      public virtual string ID { get; set; }
      public virtual string FirstName { get; set; }
      public virtual string LastName { get; set; }
      public virtual string Address { get; set; }
      public virtual int Telephone1 { get; set; }
      public virtual int Telephone2 { get; set; }
      public virtual int Age { get; set; }
      public virtual string Occupation { get; set; }
      public virtual string Gender { get; set; }
      public virtual string Room { get; set; }
  }
  
  public class PatronMap : ClassMap&lt;Patron&gt;
  {
      public PatronMap()
      {
          Id(x =&gt; x.ID);
          Map(x =&gt; x.FirstName);
          Map(x =&gt; x.LastName);
          Map(x =&gt; x.Gender);
          Map(x =&gt; x.Age);
          Map(x =&gt; x.Address);
          Map(x =&gt; x.Occupation);
          Map(x =&gt; x.Telephone1);
          Map(x =&gt; x.Telephone2);
          Map(x =&gt; x.Room);
          Table("Patrons");
      }
  }
  
  public class MemberMap : ClassMap&lt;Member&gt;
  {
      public MemberMap()
      {
          Id(x =&gt; x.ID);
          HasOne(x =&gt; x.Patron).PropertyRef(x =&gt; x.ID).Constrained();
          Map(x =&gt; x.Reference1);
          Map(x =&gt; x.Reference2);
          Map(x =&gt; x.IsRegistered);
          Table("Members");
      }
   }
  </code></pre>
  
  <p>I also have a little test, as below, to see if the things are mapped correctly or not.</p>
  
  <pre><code>    [TestMethod]
      public void MemberMap_Create_Success()
      {
          new PersistenceSpecification&lt;Member&gt;( Database.Session, new CustomEqualityComparer() )
          .CheckProperty(x =&gt; x.ID, "1")
          //I'm not quite sure about the following mapping check. How do I do HasOne check here? :-(
          .CheckReference(x =&gt; x.Patron, new Patron()
          {
              ID = "2",
              FirstName = "Foo",
              LastName = "Bar",
              Gender = "M",
              Age = 59,
              Address = "City, Coutnry",
              Telephone1 = 0123456789,
              Telephone2 = 0987654321,
              Occupation = "Learning Fluent nHibernate",
              Room = "Somewhere"
          })
          .CheckProperty(x =&gt; x.Reference1, "Ref1")
          .CheckProperty(x =&gt; x.Reference2, "Ref2")
          .CheckProperty(x =&gt; x.IsRegistered, true)
          .VerifyTheMappings();
      }
  </code></pre>
  
  <p>I'm not sure how to test HasOne mapping property in this test. Any help is appreciated. Thanks in advance.</p>