From 77b867d65e837cfbdc4c7f3db21e2fc6450a13b8 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 20:32:57 -0700 Subject: [PATCH] Testing ExceptionVerification Inconclusive logic --- .../Framework/AutoMoq/TestBaseTests.cs | 2 +- .../Framework/ExceptionVerification.cs | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs b/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs index babfd4977..94d67cda0 100644 --- a/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs +++ b/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Framework.AutoMoq 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)); } } } diff --git a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs index b0b37d03c..c30d31b1d 100644 --- a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs +++ b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs @@ -11,7 +11,6 @@ namespace NzbDrone.Core.Test.Framework public class ExceptionVerification : Target { private static List _logs = new List(); - private static List _inconclusive = new List(); protected override void Write(LogEventInfo logEvent) { @@ -24,7 +23,6 @@ namespace NzbDrone.Core.Test.Framework internal static void Reset() { _logs = new List(); - _inconclusive = new List(); } internal static void AssertNoUnexcpectedLogs() @@ -74,16 +72,23 @@ namespace NzbDrone.Core.Test.Framework 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 @@ namespace NzbDrone.Core.Test.Framework Assert.Fail(message); } - if (inconclusiveLogs.Count != 0) - { - Assert.Inconclusive(GetLogsString(inconclusiveLogs)); - } - levelLogs.ForEach(c => _logs.Remove(c)); }