public void SimpleTest()
{
bool eventHasBeenRaised = false;
var h = new EventHandler<SystemActivityMonitor.LowLevelErrorEventArgs>(
delegate( object sender, SystemActivityMonitor.LowLevelErrorEventArgs e )
{
Assert.That( e.ErrorWhileWritingLogFile, Is.Null );
Assert.That( e.ErrorMessage, Does.Contain( "The-Test-Exception-Message" ) );
Assert.That( e.ErrorMessage, Does.Contain( "Produced by SystemActivityMonitorTests.SimpleTest" ) );
Assert.That( File.ReadAllText( e.FullLogFilePath ), Is.EqualTo( e.ErrorMessage ) );
eventHasBeenRaised = true;
} );
SystemActivityMonitor.OnError += h;
try
{
ActivityMonitor.CriticalErrorCollector.Add( new CKException( "The-Test-Exception-Message" ), "Produced by SystemActivityMonitorTests.SimpleTest" );
ActivityMonitor.CriticalErrorCollector.WaitOnErrorFromBackgroundThreadsPending();
Assert.That( eventHasBeenRaised );
}
finally
{
SystemActivityMonitor.OnError -= h;
}
}