2

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?

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 < _printLines.Count;
 }
 finally
 {
   if (printFont != null)
    printFont.Dispose();
 }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Sankar Sai
  • 57
  • 6

0 Answers0