title: Testing properties with private setters
body: <p>Currently in a part of my project a domain object like below exists:</p>
  
  <pre><code>public class Address
  {
      public virtual string HouseName { get; set; }
  
      public virtual string HouseNumber { get; set; }
  
      public virtual string RoadName { get; set; }
  
      public virtual string Postcode { get; set; }
  
      public virtual string District { get; private set; }
  }
  </code></pre>
  
  <p>The District property is a calculated column in the database. Due to the requirements of the data access provider (Entity Framework) a private set is required. This is fine in normal program flow as the District never needs to be set, due to it being updated when an Address record is saved/updated in the database</p>
  
  <p>A method that I want to test looks like this:</p>
  
  <pre><code>public IEnumerable&lt;House&gt; GetHousesWithinSameDistrict (int addressId)
  {
      var addressToMatch = _addressRepository
        .FirstOrDefault(address =&gt; address.Id == addressId)
  
      return _houseRepository
        .Where(house =&gt; house.Address.District == addressToMatch.District)
  }
  </code></pre>
  
  <p>This is causing me problems when I try to set up the addressToMatch variable, as I am unable to set the District property and as such I cannot write a test to check correct matching addresses are returned.</p>
  
  <p>How should I go about setting up an Address object for this test?</p>