private void Machine_Printed(object sender, PrintEventArgs e) { if (Printed == null) { // if there are no event handlers, default to printing to the console Console.WriteLine(e.Text); } else { Printed(this, e); } }
private void TestPrint(object sender, PrintEventArgs e) { if (mExpectedOutput.Count == 0) { mErrors.Add("got \"" + e.Text + "\" when not expecting any more output"); } else { string expecting = mExpectedOutput.Dequeue(); string actual = e.Text.Replace("\n", "\\n"); if (expecting != actual) { mErrors.Add("got \"" + actual + "\" when expecting \"" + expecting + "\""); } } }