From 87cf08a365f92f9aa37bc808486405e2347de022 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 18:37:29 -0700 Subject: [PATCH 01/10] Fixed Exceptioneer. --- NzbDrone.Core/Instrumentation/LogConfiguration.cs | 4 ++-- NzbDrone/Providers/MonitoringProvider.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Core/Instrumentation/LogConfiguration.cs b/NzbDrone.Core/Instrumentation/LogConfiguration.cs index 4e93694c2..ec398ed5f 100644 --- a/NzbDrone.Core/Instrumentation/LogConfiguration.cs +++ b/NzbDrone.Core/Instrumentation/LogConfiguration.cs @@ -23,8 +23,8 @@ namespace NzbDrone.Core.Instrumentation public static void StartDbLogging() { - -#if RELEASE +#if DEBUG +#else var exTarget = new ExceptioneerTarget(); LogManager.Configuration.AddTarget("Exceptioneer", exTarget); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Error, exTarget)); diff --git a/NzbDrone/Providers/MonitoringProvider.cs b/NzbDrone/Providers/MonitoringProvider.cs index 55c80d0af..0fa5a1562 100644 --- a/NzbDrone/Providers/MonitoringProvider.cs +++ b/NzbDrone/Providers/MonitoringProvider.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Runtime.Remoting; using System.Timers; +using Exceptioneer.WindowsFormsClient; using NLog; using Ninject; @@ -106,7 +107,8 @@ namespace NzbDrone.Providers Console.WriteLine("EPIC FAIL: {0}", excepion); Logger.Fatal("EPIC FAIL: {0}", excepion); -#if RELEASE +#if DEBUG +#else new Client { ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265", From f1248d12c66674d289f81c7f1157e5af4d51475f Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 18:42:20 -0700 Subject: [PATCH 02/10] Better exception handling in NzbDrone.exe --- NzbDrone/AppMain.cs | 9 ++------- NzbDrone/Providers/MonitoringProvider.cs | 9 +++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/NzbDrone/AppMain.cs b/NzbDrone/AppMain.cs index 801ffae68..f794f9093 100644 --- a/NzbDrone/AppMain.cs +++ b/NzbDrone/AppMain.cs @@ -1,16 +1,12 @@ using System; using System.Reflection; -using NLog; using Ninject; +using NzbDrone.Providers; namespace NzbDrone { public static class AppMain { - - - private static readonly Logger Logger = LogManager.GetLogger("Host.Main"); - public static void Main(string[] args) { try @@ -21,8 +17,7 @@ namespace NzbDrone } catch (Exception e) { - Console.WriteLine(e.ToString()); - Logger.Fatal(e.ToString()); + MonitoringProvider.AppDomainException(e); } } diff --git a/NzbDrone/Providers/MonitoringProvider.cs b/NzbDrone/Providers/MonitoringProvider.cs index 0fa5a1562..1ebd317e8 100644 --- a/NzbDrone/Providers/MonitoringProvider.cs +++ b/NzbDrone/Providers/MonitoringProvider.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Providers public void Start() { - AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e)); + AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception)); AppDomain.CurrentDomain.ProcessExit += ProgramExited; AppDomain.CurrentDomain.DomainUnload += ProgramExited; @@ -43,7 +43,7 @@ namespace NzbDrone.Providers prioCheckTimer.Elapsed += EnsurePriority; prioCheckTimer.Enabled = true; - _pingTimer = new Timer(60000) {AutoReset = true}; + _pingTimer = new Timer(60000) { AutoReset = true }; _pingTimer.Elapsed += (PingServer); _pingTimer.Start(); } @@ -102,10 +102,9 @@ namespace NzbDrone.Providers } - private static void AppDomainException(object excepion) + public static void AppDomainException(Exception excepion) { Console.WriteLine("EPIC FAIL: {0}", excepion); - Logger.Fatal("EPIC FAIL: {0}", excepion); #if DEBUG #else @@ -116,6 +115,8 @@ namespace NzbDrone.Providers CurrentException = excepion as Exception }.Submit(); #endif + + Logger.Fatal("EPIC FAIL: {0}", excepion); } } } \ No newline at end of file From c55ca42c21d211c0ecda2f5af51c451e93a186cb Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 19:03:54 -0700 Subject: [PATCH 03/10] Migration is no longer executed per test, its ran once and the db is cloned after that, (faster tests, cleaner logs ;) --- NzbDrone.Core.Test/Framework/Fixtures.cs | 6 +++--- NzbDrone.Core.Test/Framework/MockLib.cs | 19 +++++++++++++------ NzbDrone.Core.Test/dbBenchmark.cs | 1 + NzbDrone.Core/Datastore/MigrationsHelper.cs | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/NzbDrone.Core.Test/Framework/Fixtures.cs b/NzbDrone.Core.Test/Framework/Fixtures.cs index 4d16f35ba..30e514579 100644 --- a/NzbDrone.Core.Test/Framework/Fixtures.cs +++ b/NzbDrone.Core.Test/Framework/Fixtures.cs @@ -21,8 +21,7 @@ namespace NzbDrone.Core.Test { try { - LogManager.Configuration = - new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false); + LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false); LogManager.ThrowExceptions = true; var exceptionVerification = new ExceptionVerification(); @@ -35,7 +34,6 @@ namespace NzbDrone.Core.Test Console.WriteLine("Unable to configure logging. " + e); } - var filesToDelete = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories); foreach (var file in filesToDelete) { @@ -45,6 +43,8 @@ namespace NzbDrone.Core.Test } catch { } } + + MockLib.CreateDataBaseTemplate(); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/Framework/MockLib.cs b/NzbDrone.Core.Test/Framework/MockLib.cs index c220858f1..237372d9b 100644 --- a/NzbDrone.Core.Test/Framework/MockLib.cs +++ b/NzbDrone.Core.Test/Framework/MockLib.cs @@ -17,20 +17,19 @@ namespace NzbDrone.Core.Test.Framework /// internal static class MockLib { - public static string[] StandardSeries - { - get { return new[] { "c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24" }; } - } + private const string DbTemplateName = "_dbtemplate.sdf"; public static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "") { - Console.WriteLine("Creating an empty PetaPoco database"); + Console.WriteLine("Cloning database from template."); if (String.IsNullOrWhiteSpace(fileName)) { fileName = Guid.NewGuid() + ".sdf"; } + File.Copy(DbTemplateName, fileName); + var connectionString = Connection.GetConnectionString(fileName); var database = Connection.GetPetaPocoDb(connectionString); @@ -38,7 +37,15 @@ namespace NzbDrone.Core.Test.Framework return database; } - public static Series GetFakeSeries(int id, string title) + public static void CreateDataBaseTemplate() + { + Console.WriteLine("Creating an empty PetaPoco database"); + var connectionString = Connection.GetConnectionString(DbTemplateName); + var database = Connection.GetPetaPocoDb(connectionString); + database.Dispose(); + } + + public static Series GetFakeSeries(int id, string title) { return Builder.CreateNew() .With(c => c.SeriesId = id) diff --git a/NzbDrone.Core.Test/dbBenchmark.cs b/NzbDrone.Core.Test/dbBenchmark.cs index 3b8b3800b..80a35b06c 100644 --- a/NzbDrone.Core.Test/dbBenchmark.cs +++ b/NzbDrone.Core.Test/dbBenchmark.cs @@ -15,6 +15,7 @@ using PetaPoco; namespace NzbDrone.Core.Test { [TestFixture] + [Category("Benchmark")] // ReSharper disable InconsistentNaming public class DbBenchmark : TestBase { diff --git a/NzbDrone.Core/Datastore/MigrationsHelper.cs b/NzbDrone.Core/Datastore/MigrationsHelper.cs index b5b74ab8e..0267ce58b 100644 --- a/NzbDrone.Core/Datastore/MigrationsHelper.cs +++ b/NzbDrone.Core/Datastore/MigrationsHelper.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Datastore EnsureDatabase(connetionString); - Logger.Info("Preparing to run database migration"); + Logger.Trace("Preparing to run database migration"); try { From 287cb03517ca2c85702b50bce2ec6701b73247a4 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 19:42:11 -0700 Subject: [PATCH 04/10] Added ignore exception type to ExceptionVerfication --- .../Framework/AutoMoq/TestBaseTests.cs | 61 +++++++++++++++++++ .../Framework/ExceptionVerification.cs | 19 +++++- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 1 + 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs diff --git a/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs b/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs new file mode 100644 index 000000000..babfd4977 --- /dev/null +++ b/NzbDrone.Core.Test/Framework/AutoMoq/TestBaseTests.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using NLog; +using NUnit.Framework; + +namespace NzbDrone.Core.Test.Framework.AutoMoq +{ + [TestFixture] + class TestBaseTests : TestBase + { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + [Test] + public void Test_should_pass_when_no_exceptions_are_logged() + { + Logger.Info("Everything is fine and dandy!"); + } + + [Test] + public void Test_should_pass_when_errors_are_excpected() + { + Logger.Error("I knew this would happer"); + ExceptionVerification.ExcpectedErrors(1); + } + + [Test] + public void Test_should_pass_when_warns_are_excpected() + { + Logger.Warn("I knew this would happer"); + ExceptionVerification.ExcpectedWarns(1); + } + + [Test] + public void Test_should_pass_when_warns_are_ignored() + { + Logger.Warn("I knew this would happer"); + Logger.Warn("I knew this would happer"); + Logger.Warn("I knew this would happer"); + ExceptionVerification.IgnoreWarns(); + } + + [Test] + public void Test_should_pass_when_errors_are_ignored() + { + Logger.Error("I knew this would happer"); + Logger.Error("I knew this would happer"); + Logger.Error("I knew this would happer"); + ExceptionVerification.IgnoreErrors(); + } + + [Test] + public void Test_should_pass_when_exception_type_is_ignored() + { + Logger.ErrorException("bad exception", new WebException("Test")); + ExceptionVerification.MarkForInconclusive(typeof(WebException)); + } + } +} diff --git a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs index 6cbabaf2d..52b9bf6ec 100644 --- a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs +++ b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs @@ -11,6 +11,7 @@ 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) { @@ -23,6 +24,7 @@ namespace NzbDrone.Core.Test.Framework internal static void Reset() { _logs = new List(); + _inconclusive = new List(); } internal static void AssertNoUnexcpectedLogs() @@ -72,9 +74,16 @@ namespace NzbDrone.Core.Test.Framework Ignore(LogLevel.Error); } + internal static void MarkForInconclusive(Type exception) + { + _inconclusive.Add(exception); + } + private static void Excpected(LogLevel level, int count) { - var levelLogs = _logs.Where(l => l.Level == level).ToList(); + var _inconclusiveLogs = _logs.Where(l => _inconclusive.Any(c => c.IsAssignableFrom(l.Exception.GetType()))).ToList(); + + var levelLogs = _logs.Except(_inconclusiveLogs).Where(l => l.Level == level).ToList(); if (levelLogs.Count != count) { @@ -82,14 +91,18 @@ namespace NzbDrone.Core.Test.Framework var message = String.Format("{0} {1}(s) were expected but {2} were logged.\n\r{3}", count, level, levelLogs.Count, GetLogsString(levelLogs)); - message = - "********************************************************************************************************************************\n\r" + message = "********************************************************************************************************************************\n\r" + message + "\n\r********************************************************************************************************************************"; Assert.Fail(message); } + if (_inconclusiveLogs.Count != 0) + { + Assert.Inconclusive(GetLogsString(_inconclusiveLogs)); + } + levelLogs.ForEach(c => _logs.Remove(c)); } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 86e4fcfdd..878721f38 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -91,6 +91,7 @@ + From 97ed59920b04f2a3bb48c712507043ce49c9bdb5 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 20:02:20 -0700 Subject: [PATCH 05/10] trying to stop team city from sending exeptioneer reports. --- NzbDrone.Core.Test/Framework/ExceptionVerification.cs | 8 ++++---- NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs index 52b9bf6ec..b0b37d03c 100644 --- a/NzbDrone.Core.Test/Framework/ExceptionVerification.cs +++ b/NzbDrone.Core.Test/Framework/ExceptionVerification.cs @@ -81,9 +81,9 @@ namespace NzbDrone.Core.Test.Framework private static void Excpected(LogLevel level, int count) { - var _inconclusiveLogs = _logs.Where(l => _inconclusive.Any(c => c.IsAssignableFrom(l.Exception.GetType()))).ToList(); + 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.Except(inconclusiveLogs).Where(l => l.Level == level).ToList(); if (levelLogs.Count != count) { @@ -98,9 +98,9 @@ namespace NzbDrone.Core.Test.Framework Assert.Fail(message); } - if (_inconclusiveLogs.Count != 0) + if (inconclusiveLogs.Count != 0) { - Assert.Inconclusive(GetLogsString(_inconclusiveLogs)); + Assert.Inconclusive(GetLogsString(inconclusiveLogs)); } levelLogs.ForEach(c => _logs.Remove(c)); diff --git a/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs b/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs index 2cd8caf76..8dbd6d29d 100644 --- a/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs +++ b/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Instrumentation { if (!Debugger.IsAttached) { - Logger.Trace("Sending Exception to Exceptioneer"); + Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName); new Client { From 1d97455e9ff20231d72ee15982ce0294f62523e6 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 20:12:48 -0700 Subject: [PATCH 06/10] Teamcity should no longer send in Exceptioneer reports --- NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs b/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs index 8dbd6d29d..c543320f3 100644 --- a/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs +++ b/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Instrumentation protected override void Write(LogEventInfo logEvent) { - if (!Debugger.IsAttached) + if (!Debugger.IsAttached && !Process.GetCurrentProcess().ProcessName.Contains("JetBrains")) { Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName); From 77b867d65e837cfbdc4c7f3db21e2fc6450a13b8 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 20:32:57 -0700 Subject: [PATCH 07/10] 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)); } From 458565d4731c2075ba5418d5db0c4d8795bef1b5 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 20:40:22 -0700 Subject: [PATCH 08/10] WebException now marks indexer tests as Inconclusive. --- NzbDrone.Core.Test/IndexerTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 6d85b1d28..33367f366 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -208,6 +208,8 @@ namespace NzbDrone.Core.Test result.Should().OnlyContain(r => r.CleanTitle == Parser.NormalizeTitle(title)); result.Should().OnlyContain(r => r.SeasonNumber == season); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(episode)); + + ExceptionVerification.MarkInconclusive(typeof(WebException)); } [TestCase("simpsons", 21, 23)] @@ -233,6 +235,8 @@ namespace NzbDrone.Core.Test result.Should().OnlyContain(r => r.CleanTitle == Parser.NormalizeTitle(title)); result.Should().OnlyContain(r => r.SeasonNumber == season); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(episode)); + + ExceptionVerification.MarkInconclusive(typeof(WebException)); } [Test] @@ -256,6 +260,8 @@ namespace NzbDrone.Core.Test result.Should().OnlyContain(r => r.CleanTitle == "simpsons"); result.Should().OnlyContain(r => r.SeasonNumber == 21); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(23)); + + ExceptionVerification.MarkInconclusive(typeof(WebException)); } [Test] @@ -280,6 +286,8 @@ namespace NzbDrone.Core.Test result.Should().OnlyContain(r => r.SeasonNumber == 1); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(19)); + ExceptionVerification.MarkInconclusive(typeof(WebException)); + } [Test] @@ -303,6 +311,8 @@ namespace NzbDrone.Core.Test result.Should().OnlyContain(r => r.CleanTitle == "bluebloods"); result.Should().OnlyContain(r => r.SeasonNumber == 1); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(19)); + + ExceptionVerification.MarkInconclusive(typeof(WebException)); } From 288359627eeb5e5351dffbfc06c183e27308928f Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 20:51:15 -0700 Subject: [PATCH 09/10] WebException now marks indexer tests as Inconclusive. --- NzbDrone.Core.Test/IndexerTests.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 33367f366..40ab07a1a 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\newbin_none_english.xml")); - + var newzbin = mocker.Resolve(); var parseResults = newzbin.FetchRss(); @@ -204,12 +204,12 @@ namespace NzbDrone.Core.Test var result = mocker.Resolve().FetchEpisode(title, season, episode); + ExceptionVerification.MarkInconclusive(typeof(WebException)); + result.Should().NotBeEmpty(); result.Should().OnlyContain(r => r.CleanTitle == Parser.NormalizeTitle(title)); result.Should().OnlyContain(r => r.SeasonNumber == season); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(episode)); - - ExceptionVerification.MarkInconclusive(typeof(WebException)); } [TestCase("simpsons", 21, 23)] @@ -231,12 +231,12 @@ namespace NzbDrone.Core.Test var result = mocker.Resolve().FetchEpisode(title, season, episode); + ExceptionVerification.MarkInconclusive(typeof(WebException)); + result.Should().NotBeEmpty(); result.Should().OnlyContain(r => r.CleanTitle == Parser.NormalizeTitle(title)); result.Should().OnlyContain(r => r.SeasonNumber == season); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(episode)); - - ExceptionVerification.MarkInconclusive(typeof(WebException)); } [Test] @@ -256,12 +256,12 @@ namespace NzbDrone.Core.Test var result = mocker.Resolve().FetchEpisode("Simpsons", 21, 23); + ExceptionVerification.MarkInconclusive(typeof(WebException)); + result.Should().NotBeEmpty(); result.Should().OnlyContain(r => r.CleanTitle == "simpsons"); result.Should().OnlyContain(r => r.SeasonNumber == 21); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(23)); - - ExceptionVerification.MarkInconclusive(typeof(WebException)); } [Test] @@ -281,13 +281,12 @@ namespace NzbDrone.Core.Test var result = mocker.Resolve().FetchEpisode("Blue Bloods", 1, 19); + ExceptionVerification.MarkInconclusive(typeof(WebException)); + result.Should().NotBeEmpty(); result.Should().OnlyContain(r => r.CleanTitle == "bluebloods"); result.Should().OnlyContain(r => r.SeasonNumber == 1); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(19)); - - ExceptionVerification.MarkInconclusive(typeof(WebException)); - } [Test] @@ -307,12 +306,12 @@ namespace NzbDrone.Core.Test var result = mocker.Resolve().FetchEpisode("Blue Bloods", 1, 19); + ExceptionVerification.MarkInconclusive(typeof(WebException)); + result.Should().NotBeEmpty(); result.Should().OnlyContain(r => r.CleanTitle == "bluebloods"); result.Should().OnlyContain(r => r.SeasonNumber == 1); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(19)); - - ExceptionVerification.MarkInconclusive(typeof(WebException)); } From 2e174c03c9a730c1cc90dce4ef0f308fa27efc0f Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 16 Oct 2011 21:09:43 -0700 Subject: [PATCH 10/10] ExceptioneerTarget Tweaks --- .../Instrumentation/ExceptioneerTarget.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs b/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs index c543320f3..3805eda37 100644 --- a/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs +++ b/NzbDrone.Core/Instrumentation/ExceptioneerTarget.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using Exceptioneer.WindowsFormsClient; using NLog; using NLog.Targets; @@ -12,17 +11,18 @@ namespace NzbDrone.Core.Instrumentation protected override void Write(LogEventInfo logEvent) { - if (!Debugger.IsAttached && !Process.GetCurrentProcess().ProcessName.Contains("JetBrains")) - { - Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName); + if (logEvent == null || logEvent.Exception == null) return; + if (Debugger.IsAttached || Process.GetCurrentProcess().ProcessName.Contains("JetBrains")) return; + + Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName); + + new Client + { + ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265", + ApplicationName = "NZBDrone", + CurrentException = logEvent.Exception + }.Submit(); - new Client - { - ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265", - ApplicationName = "NZBDrone", - CurrentException = logEvent.Exception - }.Submit(); - } } } } \ No newline at end of file