ExceptionVerification improvements

pull/7/merge
kay.one 14 years ago
parent a6ad977114
commit 4e8dd47e27

@ -27,17 +27,9 @@ namespace NzbDrone.Core.Test.Framework
internal static void AssertNoError() internal static void AssertNoError()
{ {
if (_logs.Count != 0) ExcpectedFatals(0);
{ ExcpectedErrors(0);
string errors = GetLogsString(_logs); ExcpectedWarns(0);
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);
}
} }
private static string GetLogsString(IEnumerable<LogEventInfo> logs) private static string GetLogsString(IEnumerable<LogEventInfo> logs)
@ -48,9 +40,9 @@ namespace NzbDrone.Core.Test.Framework
string exception = ""; string exception = "";
if (log.Exception != null) 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; return errors;
} }
@ -86,8 +78,14 @@ namespace NzbDrone.Core.Test.Framework
if (levelLogs.Count != count) if (levelLogs.Count != count)
{ {
var message = String.Format("{0} {1}(s) were expected but {2} were logged.\n\r{3}", 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); Assert.Fail(message);
} }

Loading…
Cancel
Save