title: Unit tests to catch InvalidDataContractException in WCF
body: <p>I'm looking for a way to unit test all the DTOs I'm sending back over my WCF interfaces.  I want to avoid run-time errors like the following:</p>
  
  <pre><code>System.Runtime.Serialization.InvalidDataContractException 
  No set method for property 'Bar' in type 'Foo'.
  </code></pre>
  
  <p>For example in the following I would want the unit test to catch the above exception.</p>
  
  <pre><code>[DataContract]
  public class Foo
  {
      [DataMember]
      public decimal Bar { get { return 0; } }
  }
  </code></pre>