mirror of
https://github.com/Radarr/Radarr
synced 2024-12-24 00:42:38 +00:00
ExceptionVerification improvements
This commit is contained in:
parent
a6ad977114
commit
4e8dd47e27
1 changed files with 12 additions and 14 deletions
|
@ -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<LogEventInfo> logs)
|
||||
|
@ -48,9 +40,9 @@ private static string GetLogsString(IEnumerable<LogEventInfo> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue