public void Writes_InnerException_To_File() { Exception outer = null; Exception inner = null; using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist())) { try { throw new Exception("This is the inner exception message"); } catch (Exception caught) { inner = caught; } try { throw new Exception("This is the outer exception message", inner); } catch (Exception caught) { outer = caught; } logger.Write("Exception occured!", outer); } Assert.That( File.ReadAllText(FileMocks.FileThatDoesNotExist()), Is.StringContaining(inner.Message).And.StringContaining(inner.StackTrace) ); }
public void Writes_Exception_To_File() { Exception ex = null; using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist())) { try { throw new Exception("This is the exception message"); } catch (Exception caught) { ex = caught; } logger.Write("Exception occured!", ex); } Assert.That( File.ReadAllText(FileMocks.FileThatDoesNotExist()), Does.Contain(ex.Message).And.Contains(ex.StackTrace) ); }