From 4e8dd47e277c556899e89e3d3332e8e5b8157bb3 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 26 May 2011 20:04:36 -0700 Subject: [PATCH] ExceptionVerification improvements --- .../Framework/ExceptionVerification.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs index 9dbb4d5b0..4b9d87ac3 100644 --- a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs +++ b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs @@ -27,17 +27,9 @@ internal static void Reset() internal static void AssertNoError() { - if (_logs.Count != 0) - { - string errors = GetLogsString(_logs); - - var message = String.Format("{0} unexpected Fatal/Error/Warning were logged during execution.\n\r Use ExceptionVerification.Excpected methods if errors are excepted for this test.{1}{2}", - _logs.Count, - Environment.NewLine, - errors); - - Assert.Fail(message); - } + ExcpectedFatals(0); + ExcpectedErrors(0); + ExcpectedWarns(0); } private static string GetLogsString(IEnumerable logs) @@ -48,9 +40,9 @@ private static string GetLogsString(IEnumerable logs) string exception = ""; if (log.Exception != null) { - exception = log.Exception.ToString(); + exception = log.Exception.Message; } - errors += Environment.NewLine + String.Format("[{0}] {1}: {2} {3}", log.Level, log.LoggerName, log.FormattedMessage, exception); + errors += Environment.NewLine + String.Format("[{0}] {1}: {2} [{3}]", log.Level, log.LoggerName, log.FormattedMessage, exception); } return errors; } @@ -86,8 +78,14 @@ private static void Excpected(LogLevel level, int count) if (levelLogs.Count != count) { + var message = String.Format("{0} {1}(s) were expected but {2} were logged.\n\r{3}", - count, level, _logs.Count, GetLogsString(levelLogs)); + count, level, levelLogs.Count, GetLogsString(levelLogs)); + + message = + "********************************************************************************************************************************\n\r" + + message + + "\n\r********************************************************************************************************************************"; Assert.Fail(message); }