title: Unit testing issue c# object getProperties
body: <p>I have a c# class that gets object property names.</p>
  
  <pre><code>public class MyClass
  {
      public int Id { get; set; }
      public int Name { get; set; }
  }
  
  public class Parser&lt;T&gt;
  {
      public IEnumerable&lt;string&gt; Parse(T item)
      {
          const BindingFlags flag = BindingFlags.Instance | BindingFlags.Public;
  
          return item.GetType().GetProperties(flag).Select(p =&gt; p.Name);
      }
  }
  </code></pre>
  
  <p>I want to test this methot.</p>
  
  <pre><code>    [Test]
      public void TestMethod()
      {
          var parser = new Parser&lt;MyClass&gt;();
          var names = parser.Parse(new MyClass()).ToArray();
  
          Assert.IsTrue(names[1] == "Name");
      }
  </code></pre>
  
  <p>But this throws an exception <strong>System.NullReferenceException</strong>. But I put breakpoint and see <code>names</code> array have two items.</p>
  
  <p><code>Assert.IsTrue(names[1] == "Name");</code> row throws exception. But is has 2 items.</p>
  
  <blockquote>
    <p>Test 'M:ParsProejct.TestsClass.TestMethod.' failed: Object reference
    not set to an instance of an object.</p>
  </blockquote>