title: How to invoke unit test a Print Event handler in c#
body: <p>I have below method which will get invoked when I call Print() method. I need to unit test the same. Is there any suggestions on how to do this?</p>
  
  <pre><code>internal PrintRemovalController(IApplicationContextHelper applicationContextHelper)
  {
    _applicationContextHelper = applicationContextHelper;
  
    using (PrintDocument)
      _printDocument.PrintPage += PrintDocument_PrintPage;
  }
  
  public void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
  {
    Font printFont = null;
    try
    {
      PrintDetails pd;
      do
      {
          pd = _printLines[_printPosition];
          printFont = new Font("Courier New", 11, pd.Style);
  
          if (pd.Text != "PAGE~~END")
              e.Graphics.DrawString(pd.Text, printFont, Brushes.Black, pd.XPos, d.YPos);
  
          _printPosition++;
      }
      while (pd.Text != "PAGE~~END");
  
      e.HasMorePages = _printPosition &lt; _printLines.Count;
   }
   finally
   {
     if (printFont != null)
      printFont.Dispose();
   }
  }
  </code></pre>