From af3282630f77548a95826331ba7a412106222a19 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 30 Mar 2013 15:43:19 -0700 Subject: [PATCH] event aggregator is singleton to prevent it from being disposed. --- NzbDrone.Common/Eventing/EventAggregator.cs | 4 ++-- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 2 +- .../{TvDbProviderTest.cs => TvDbProxyFixture.cs} | 9 ++++++++- NzbDrone.Core/ContainerExtensions.cs | 7 ++++++- NzbDrone.Core/Tv/EpisodeService.cs | 8 +++++++- NzbDrone.Core/Tv/SeriesService.cs | 2 ++ 6 files changed, 26 insertions(+), 6 deletions(-) rename NzbDrone.Core.Test/ProviderTests/{TvDbProviderTest.cs => TvDbProxyFixture.cs} (84%) diff --git a/NzbDrone.Common/Eventing/EventAggregator.cs b/NzbDrone.Common/Eventing/EventAggregator.cs index 0c6b373ae..58a7290e4 100644 --- a/NzbDrone.Common/Eventing/EventAggregator.cs +++ b/NzbDrone.Common/Eventing/EventAggregator.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Common.Eventing { _logger.Debug("{0} -> {1}", message.GetType().Name, handler.GetType().Name); handler.Handle(message); - _logger.Debug("{0} -#> {1}", message.GetType().Name, handler.GetType().Name); + _logger.Debug("{0} <- {1}", message.GetType().Name, handler.GetType().Name); } @@ -37,7 +37,7 @@ namespace NzbDrone.Common.Eventing { _logger.Debug("{0} ~> {1}", message.GetType().Name, handlerLocal.GetType().Name); handlerLocal.HandleAsync(message); - _logger.Debug("{0} ~#> {1}", message.GetType().Name, handlerLocal.GetType().Name); + _logger.Debug("{0} <~ {1}", message.GetType().Name, handlerLocal.GetType().Name); }); } } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 185f4872e..dd35ad5cc 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -245,7 +245,7 @@ - + diff --git a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/TvDbProxyFixture.cs similarity index 84% rename from NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs rename to NzbDrone.Core.Test/ProviderTests/TvDbProxyFixture.cs index 721f71840..c1364f95f 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvDbProxyFixture.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] - public class TvDbProviderTest : CoreTest + public class TvDbProxyFixture : CoreTest { [TestCase("The Simpsons")] [TestCase("Family Guy")] @@ -50,5 +50,12 @@ namespace NzbDrone.Core.Test.ProviderTests details.Should().NotBeNull(); details.Covers.Value.Should().NotBeEmpty(); } + + [Test] + public void should_be_able_to_get_list_of_episodes() + { + var details = Subject.GetEpisodes(75978); + details.Should().NotBeEmpty(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/ContainerExtensions.cs b/NzbDrone.Core/ContainerExtensions.cs index 6e154e998..f2352ff15 100644 --- a/NzbDrone.Core/ContainerExtensions.cs +++ b/NzbDrone.Core/ContainerExtensions.cs @@ -4,6 +4,7 @@ using System.Reflection; using Autofac; using NLog; using NzbDrone.Common; +using NzbDrone.Common.Eventing; using NzbDrone.Core.Datastore; using NzbDrone.Core.ExternalNotification; using NzbDrone.Core.IndexerSearch; @@ -23,7 +24,11 @@ namespace NzbDrone.Core containerBuilder.RegisterAssembly("NzbDrone.Core"); containerBuilder.InitDatabase(); - + + + containerBuilder.RegisterType() + .As().SingleInstance(); + containerBuilder.RegisterModule(); } diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index dd27452e3..a7b44711e 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -40,7 +40,8 @@ namespace NzbDrone.Core.Tv public class EpisodeService : IEpisodeService, IHandle, IHandle, - IHandleAsync + IHandleAsync, + IHandleAsync { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); @@ -399,5 +400,10 @@ namespace NzbDrone.Core.Tv UpdateEpisode(episode); } } + + public void HandleAsync(SeriesAddedEvent message) + { + RefreshEpisodeInfo(message.Series); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index 6a92a5517..adf56950c 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -80,7 +80,9 @@ namespace NzbDrone.Core.Tv try { if (series.TvRageId == 0) + { series = _tvRageMappingProvider.FindMatchingTvRageSeries(series); + } } catch (Exception ex)