title: Unit testing simple Tree structure manipulations
body: <p>Given a very simple structure such as this:</p>
  
  <pre><code>public class TreeNode
  {
      public int ID { get; set; }
      public List&lt;TreeNode&gt; Children { get; set; }
  }
  </code></pre>
  
  <p><em><code>TreeNode</code> may have other properties.</em></p>
  
  <p>And when used in the following manner:</p>
  
  <pre><code>var tree = new List&lt;TreeNode&gt;(); //no root node
  </code></pre>
  
  <p>If I perform add/update/remove operations on the tree based on certain criteria.  For example, removal of a node based on one or more of the <em>other properties</em> I mentioned above, I'd like to compare the tree graph before and after the changes and then via unit tests verify some of the follow:</p>
  
  <ul>
  <li>Tree remains unchanged</li>
  <li>Specified nodes are removed</li>
  <li>Specified nodes are added</li>
  <li>Specified nodes are updated</li>
  <li>The 3 above whilst also verifying that the rest of the tree is unchanged.</li>
  </ul>
  
  <p>Ideally, I'd throw an expection listing the nodes that were not found, not expected etc.  However, at this stage I'd be happy with a true/false to my check.</p>
  
  <p>Are there any known patterns/alogorithms existing projects that would help with this?</p>
  
  <p>I am happy for pseudo-code or examples in other languages as long as they don't rely on features I can't replicate in .NET.</p>
  
  <p>My tree is unlikely to get to more than 7 or 8 levels deep and no more than a hundred nodes in total as it will be test data so brute force looping is fine and performance isn't a consideration at this time.</p>
  
  <p>I'm really looking for tips, tricks, advice, code on how to approach this.</p>
  
  <p>TIA</p>