title: Unit testing and checking private variable value
body: <p>I am writing unit tests with C#, NUnit and Rhino Mocks.
  Here are the relevant parts of a class I am testing:</p>
  
  <pre><code>public class ClassToBeTested
  {
      private IList&lt;object&gt; insertItems = new List&lt;object&gt;();
  
      public bool OnSave(object entity, object id)
      {
          var auditable = entity as IAuditable;
          if (auditable != null) insertItems.Add(entity);
  
          return false;            
      }
  }
  </code></pre>
  
  <p>I want to test the values in insertItems after a call to OnSave:</p>
  
  <pre><code>[Test]
  public void OnSave_Adds_Object_To_InsertItems_Array()
  {
       Setup();
  
       myClassToBeTested.OnSave(auditableObject, null);
  
       // Check auditableObject has been added to insertItems array            
  }
  </code></pre>
  
  <p>What is the best practice for this? I have considered adding insertItems as a Property with a public get, or injecting a List into ClassToBeTested, but not sure I should be modifying the code for purposes of testing.</p>
  
  <p>I have read many posts on testing private methods and refactoring, but this is such a simple class I wondered what is the best option.</p>