mirror of
https://github.com/Radarr/Radarr
synced 2025-01-30 19:31:35 +00:00
Testing ExceptionVerification Inconclusive logic
This commit is contained in:
parent
1d97455e9f
commit
77b867d65e
2 changed files with 12 additions and 12 deletions
|
@ -55,7 +55,7 @@ public void Test_should_pass_when_errors_are_ignored()
|
|||
public void Test_should_pass_when_exception_type_is_ignored()
|
||||
{
|
||||
Logger.ErrorException("bad exception", new WebException("Test"));
|
||||
ExceptionVerification.MarkForInconclusive(typeof(WebException));
|
||||
ExceptionVerification.MarkInconclusive(typeof(WebException));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace NzbDrone.Core.Test.Framework
|
|||
public class ExceptionVerification : Target
|
||||
{
|
||||
private static List<LogEventInfo> _logs = new List<LogEventInfo>();
|
||||
private static List<Type> _inconclusive = new List<Type>();
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
|
@ -24,7 +23,6 @@ protected override void Write(LogEventInfo logEvent)
|
|||
internal static void Reset()
|
||||
{
|
||||
_logs = new List<LogEventInfo>();
|
||||
_inconclusive = new List<Type>();
|
||||
}
|
||||
|
||||
internal static void AssertNoUnexcpectedLogs()
|
||||
|
@ -74,16 +72,23 @@ internal static void IgnoreErrors()
|
|||
Ignore(LogLevel.Error);
|
||||
}
|
||||
|
||||
internal static void MarkForInconclusive(Type exception)
|
||||
internal static void MarkInconclusive(Type exception)
|
||||
{
|
||||
_inconclusive.Add(exception);
|
||||
var inconclusiveLogs = _logs.Where(l => l.Exception.GetType() == exception).ToList();
|
||||
|
||||
if (inconclusiveLogs.Count != 0)
|
||||
{
|
||||
inconclusiveLogs.ForEach(c => _logs.Remove(c));
|
||||
Assert.Inconclusive(GetLogsString(inconclusiveLogs));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void Excpected(LogLevel level, int count)
|
||||
{
|
||||
var inconclusiveLogs = _logs.Where(l => _inconclusive.Any(c => c == l.Exception.GetType())).ToList();
|
||||
|
||||
var levelLogs = _logs.Except(inconclusiveLogs).Where(l => l.Level == level).ToList();
|
||||
|
||||
var levelLogs = _logs.Where(l => l.Level == level).ToList();
|
||||
|
||||
if (levelLogs.Count != count)
|
||||
{
|
||||
|
@ -98,11 +103,6 @@ private static void Excpected(LogLevel level, int count)
|
|||
Assert.Fail(message);
|
||||
}
|
||||
|
||||
if (inconclusiveLogs.Count != 0)
|
||||
{
|
||||
Assert.Inconclusive(GetLogsString(inconclusiveLogs));
|
||||
}
|
||||
|
||||
levelLogs.ForEach(c => _logs.Remove(c));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue