title: How to loop through and test values of properties of already instantiated object in .NET
body: <p>have "Googled the cr*p" out of this one so apologies if the answer is either on here, or fairly simple.</p>
  
  <p>I am writing Unit tests. In this particular one I am instantiating an object using a parameterless constructor. When instantiating using that constructor none of its properties will be set.</p>
  
  <p>I then, as part of the test, want to "loop" through the properties and assert that they are either "null", "0" or "false" (which would be the correct state).</p>
  
  <p>I know it sounds like a dumb thing to do, but if I can do this, then I can write more efficient and readable tests for everything else.</p>
  
  <p>I know I can "loop" through the properties of a "Type", but that's not an instantiated object "of type". It's a "Type" object.</p>
  
  <p>In my head it should be (but obviously isn't) the following:</p>
  
  <pre><code>var target = new MyObject();
  
  foreach(var property in target.GetProperties())
  {
      Assert.IsNull(property);
  }
  </code></pre>
  
  <p>Anyone?</p>