diff --git a/NzbDrone.Api/NancyBootstrapper.cs b/NzbDrone.Api/NancyBootstrapper.cs index 7bc4649f9..b295d64c6 100644 --- a/NzbDrone.Api/NancyBootstrapper.cs +++ b/NzbDrone.Api/NancyBootstrapper.cs @@ -6,7 +6,7 @@ using NzbDrone.Api.ErrorManagement; using NzbDrone.Api.Extensions; using NzbDrone.Api.Frontend; using NzbDrone.Common; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.Lifecycle; using TinyIoC; @@ -30,7 +30,7 @@ namespace NzbDrone.Api AutomapperBootstraper.InitializeAutomapper(); RegisterReporting(container); - container.Resolve().Publish(new ApplicationStartedEvent()); + container.Resolve().Publish(new ApplicationStartedEvent()); ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve().HandleException); } @@ -73,7 +73,7 @@ namespace NzbDrone.Api public void Shutdown() { - ApplicationContainer.Resolve().Publish(new ApplicationShutdownRequested()); + ApplicationContainer.Resolve().Publish(new ApplicationShutdownRequested()); } } } \ No newline at end of file diff --git a/NzbDrone.Api/QualityProfiles/QualityProfilesModule.cs b/NzbDrone.Api/QualityProfiles/QualityProfilesModule.cs index 6b9d72b52..979d4d223 100644 --- a/NzbDrone.Api/QualityProfiles/QualityProfilesModule.cs +++ b/NzbDrone.Api/QualityProfiles/QualityProfilesModule.cs @@ -1,10 +1,7 @@ using System.Collections.Generic; -using System.Linq; using AutoMapper; using Nancy; using NzbDrone.Api.Extensions; -using NzbDrone.Core.Providers; -using NzbDrone.Api.QualityType; using NzbDrone.Core.Qualities; namespace NzbDrone.Api.QualityProfiles diff --git a/NzbDrone.Api/QualityType/QualitySizeModule.cs b/NzbDrone.Api/QualityType/QualitySizeModule.cs index f64df9688..0f2165bff 100644 --- a/NzbDrone.Api/QualityType/QualitySizeModule.cs +++ b/NzbDrone.Api/QualityType/QualitySizeModule.cs @@ -3,8 +3,6 @@ using System.Linq; using AutoMapper; using Nancy; using NzbDrone.Api.Extensions; -using NzbDrone.Api.QualityProfiles; -using NzbDrone.Core.Providers; using NzbDrone.Core.Qualities; namespace NzbDrone.Api.QualityType diff --git a/NzbDrone.App.Test/ContainerFixture.cs b/NzbDrone.App.Test/ContainerFixture.cs index bcf6a5c92..dc8b4bec6 100644 --- a/NzbDrone.App.Test/ContainerFixture.cs +++ b/NzbDrone.App.Test/ContainerFixture.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using NUnit.Framework; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Test.Common; @@ -14,7 +14,7 @@ namespace NzbDrone.App.Test [Test] public void should_be_able_to_resolve_event_handlers() { - MainAppContainerBuilder.BuildContainer().Resolve>().Should().NotBeEmpty(); + MainAppContainerBuilder.BuildContainer().Resolve>().Should().NotBeEmpty(); } [Test] diff --git a/NzbDrone.Common.Test/EventingTests/EventAggregatorTests.cs b/NzbDrone.Common.Test/EventingTests/EventAggregatorTests.cs index d064b635d..0576d578c 100644 --- a/NzbDrone.Common.Test/EventingTests/EventAggregatorTests.cs +++ b/NzbDrone.Common.Test/EventingTests/EventAggregatorTests.cs @@ -2,7 +2,7 @@ using System.Linq; using Moq; using NUnit.Framework; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Test.Common; namespace NzbDrone.Common.Test.EventingTests @@ -17,7 +17,7 @@ namespace NzbDrone.Common.Test.EventingTests var intHandler = new Mock>(); - var aggregator = new EventAggregator(TestLogger, () => new List { intHandler.Object }); + var aggregator = new MessageAggregator(TestLogger, () => new List { intHandler.Object }); aggregator.Publish(eventA); intHandler.Verify(c => c.Handle(eventA), Times.Once()); @@ -30,7 +30,7 @@ namespace NzbDrone.Common.Test.EventingTests var intHandler1 = new Mock>(); var intHandler2 = new Mock>(); - var aggregator = new EventAggregator(TestLogger, () => new List { intHandler1.Object, intHandler2.Object }); + var aggregator = new MessageAggregator(TestLogger, () => new List { intHandler1.Object, intHandler2.Object }); aggregator.Publish(eventA); intHandler1.Verify(c => c.Handle(eventA), Times.Once()); @@ -44,7 +44,7 @@ namespace NzbDrone.Common.Test.EventingTests var aHandler = new Mock>(); var bHandler = new Mock>(); - var aggregator = new EventAggregator(TestLogger, () => new List { aHandler.Object, bHandler.Object }); + var aggregator = new MessageAggregator(TestLogger, () => new List { aHandler.Object, bHandler.Object }); aggregator.Publish(eventA); diff --git a/NzbDrone.Common/Eventing/IEvent.cs b/NzbDrone.Common/Eventing/IEvent.cs deleted file mode 100644 index eabbd3209..000000000 --- a/NzbDrone.Common/Eventing/IEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Linq; - -namespace NzbDrone.Common.Eventing -{ - public interface IEvent - { - } -} \ No newline at end of file diff --git a/NzbDrone.Common/Messaging/ICommand.cs b/NzbDrone.Common/Messaging/ICommand.cs new file mode 100644 index 000000000..d9f8049ba --- /dev/null +++ b/NzbDrone.Common/Messaging/ICommand.cs @@ -0,0 +1,6 @@ +namespace NzbDrone.Common.Messaging +{ + public interface ICommand : IMessage + { + } +} \ No newline at end of file diff --git a/NzbDrone.Common/Messaging/IEvent.cs b/NzbDrone.Common/Messaging/IEvent.cs new file mode 100644 index 000000000..953709c13 --- /dev/null +++ b/NzbDrone.Common/Messaging/IEvent.cs @@ -0,0 +1,6 @@ +namespace NzbDrone.Common.Messaging +{ + public interface IEvent : IMessage + { + } +} \ No newline at end of file diff --git a/NzbDrone.Common/Eventing/IHandle.cs b/NzbDrone.Common/Messaging/IHandle.cs similarity index 60% rename from NzbDrone.Common/Eventing/IHandle.cs rename to NzbDrone.Common/Messaging/IHandle.cs index d33a4dc32..39657dce9 100644 --- a/NzbDrone.Common/Eventing/IHandle.cs +++ b/NzbDrone.Common/Messaging/IHandle.cs @@ -1,12 +1,10 @@ -using System.Linq; - -namespace NzbDrone.Common.Eventing +namespace NzbDrone.Common.Messaging { /// /// Denotes a class which can handle a particular type of message. /// /// The type of message to handle. - public interface IHandle : IHandle where TEvent : IEvent + public interface IHandle : IProcessMessage where TEvent : IEvent { /// /// Handles the message synchronously. @@ -19,7 +17,7 @@ namespace NzbDrone.Common.Eventing /// Denotes a class which can handle a particular type of message. /// /// The type of message to handle. - public interface IHandleAsync : IHandleAsync where TEvent : IEvent + public interface IHandleAsync : IProcessMessageAsync where TEvent : IEvent { /// /// Handles the message asynchronously. @@ -27,14 +25,4 @@ namespace NzbDrone.Common.Eventing /// The message. void HandleAsync(TEvent message); } - - /// - /// A marker interface for classes that subscribe to messages. - /// - public interface IHandle { } - - /// - /// A marker interface for classes that subscribe to messages. - /// - public interface IHandleAsync : IHandle { } } \ No newline at end of file diff --git a/NzbDrone.Common/Messaging/IMessage.cs b/NzbDrone.Common/Messaging/IMessage.cs new file mode 100644 index 000000000..1c7b25371 --- /dev/null +++ b/NzbDrone.Common/Messaging/IMessage.cs @@ -0,0 +1,6 @@ +namespace NzbDrone.Common.Messaging +{ + public interface IMessage + { + } +} \ No newline at end of file diff --git a/NzbDrone.Common/Eventing/IEventAggregator.cs b/NzbDrone.Common/Messaging/IMessageAggregator.cs similarity index 53% rename from NzbDrone.Common/Eventing/IEventAggregator.cs rename to NzbDrone.Common/Messaging/IMessageAggregator.cs index 05ca2eba1..f16c5b4c1 100644 --- a/NzbDrone.Common/Eventing/IEventAggregator.cs +++ b/NzbDrone.Common/Messaging/IMessageAggregator.cs @@ -1,14 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace NzbDrone.Common.Eventing +namespace NzbDrone.Common.Messaging { /// /// Enables loosely-coupled publication of events. /// - public interface IEventAggregator + public interface IMessageAggregator { void Publish(TEvent message) where TEvent : IEvent; + void Execute(TCommand message) where TCommand : ICommand; } } \ No newline at end of file diff --git a/NzbDrone.Common/Messaging/IProcessMessage.cs b/NzbDrone.Common/Messaging/IProcessMessage.cs new file mode 100644 index 000000000..e39188c62 --- /dev/null +++ b/NzbDrone.Common/Messaging/IProcessMessage.cs @@ -0,0 +1,12 @@ +namespace NzbDrone.Common.Messaging +{ + /// + /// A marker interface for classes that subscribe to messages. + /// + public interface IProcessMessage { } + + /// + /// A marker interface for classes that subscribe to messages. + /// + public interface IProcessMessageAsync : IProcessMessage { } +} \ No newline at end of file diff --git a/NzbDrone.Common/Eventing/EventAggregator.cs b/NzbDrone.Common/Messaging/MessageAggregator.cs similarity index 76% rename from NzbDrone.Common/Eventing/EventAggregator.cs rename to NzbDrone.Common/Messaging/MessageAggregator.cs index 11bfa52f2..cba7e6227 100644 --- a/NzbDrone.Common/Eventing/EventAggregator.cs +++ b/NzbDrone.Common/Messaging/MessageAggregator.cs @@ -4,14 +4,14 @@ using System.Linq; using System.Threading.Tasks; using NLog; -namespace NzbDrone.Common.Eventing +namespace NzbDrone.Common.Messaging { - public class EventAggregator : IEventAggregator + public class MessageAggregator : IMessageAggregator { private readonly Logger _logger; - private readonly Func> _handlers; + private readonly Func> _handlers; - public EventAggregator(Logger logger, Func> handlers) + public MessageAggregator(Logger logger, Func> handlers) { _logger = logger; _handlers = handlers; @@ -40,5 +40,10 @@ namespace NzbDrone.Common.Eventing }); } } + + public void Execute(TCommand message) where TCommand : ICommand + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index 204ea9427..e9f268b8a 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -105,10 +105,13 @@ - - - - + + + + + + + diff --git a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs index 55dde1e13..f7f547369 100644 --- a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs +++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Tv; diff --git a/NzbDrone.Core/Download/DownloadService.cs b/NzbDrone.Core/Download/DownloadService.cs index 2eb8996b8..560e2d0d1 100644 --- a/NzbDrone.Core/Download/DownloadService.cs +++ b/NzbDrone.Core/Download/DownloadService.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Model; @@ -21,16 +21,16 @@ namespace NzbDrone.Core.Download { private readonly IProvideDownloadClient _downloadClientProvider; private readonly IConfigService _configService; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly Logger _logger; public DownloadService(IProvideDownloadClient downloadClientProvider, IConfigService configService, - IEventAggregator eventAggregator, Logger logger) + IMessageAggregator messageAggregator, Logger logger) { _downloadClientProvider = downloadClientProvider; _configService = configService; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _logger = logger; } @@ -50,7 +50,7 @@ namespace NzbDrone.Core.Download if (success) { _logger.Info("Report sent to download client. {0}", downloadTitle); - _eventAggregator.Publish(new EpisodeGrabbedEvent(episode)); + _messageAggregator.Publish(new EpisodeGrabbedEvent(episode)); } return success; diff --git a/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs b/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs index af4bce9c9..7f3247f33 100644 --- a/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs +++ b/NzbDrone.Core/Download/EpisodeGrabbedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Model; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; diff --git a/NzbDrone.Core/Download/SeriesRenamedEvent.cs b/NzbDrone.Core/Download/SeriesRenamedEvent.cs index 32f8036d4..0de78d7d1 100644 --- a/NzbDrone.Core/Download/SeriesRenamedEvent.cs +++ b/NzbDrone.Core/Download/SeriesRenamedEvent.cs @@ -1,5 +1,5 @@ using System.Linq; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Download diff --git a/NzbDrone.Core/ExternalNotification/ExternalNotificationBase.cs b/NzbDrone.Core/ExternalNotification/ExternalNotificationBase.cs index b11d19e40..52a7ead41 100644 --- a/NzbDrone.Core/ExternalNotification/ExternalNotificationBase.cs +++ b/NzbDrone.Core/ExternalNotification/ExternalNotificationBase.cs @@ -1,6 +1,6 @@ using System; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Tv; diff --git a/NzbDrone.Core/History/HistoryService.cs b/NzbDrone.Core/History/HistoryService.cs index 6e534f8af..06a478553 100644 --- a/NzbDrone.Core/History/HistoryService.cs +++ b/NzbDrone.Core/History/HistoryService.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; using NzbDrone.Core.Tv; diff --git a/NzbDrone.Core/Indexers/IndexerService.cs b/NzbDrone.Core/Indexers/IndexerService.cs index 68034e26a..71855ab00 100644 --- a/NzbDrone.Core/Indexers/IndexerService.cs +++ b/NzbDrone.Core/Indexers/IndexerService.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; diff --git a/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs b/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs index a458df257..8b3edc513 100644 --- a/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs +++ b/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Indexers { diff --git a/NzbDrone.Core/Indexers/IndexerWithSetting.cs b/NzbDrone.Core/Indexers/IndexerWithSetting.cs index 9fec086f2..7eda6a8da 100644 --- a/NzbDrone.Core/Indexers/IndexerWithSetting.cs +++ b/NzbDrone.Core/Indexers/IndexerWithSetting.cs @@ -1,5 +1,5 @@ using System; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Indexers { diff --git a/NzbDrone.Core/Indexers/Newznab/NewznabService.cs b/NzbDrone.Core/Indexers/Newznab/NewznabService.cs index 1cbcdd828..520992ac6 100644 --- a/NzbDrone.Core/Indexers/Newznab/NewznabService.cs +++ b/NzbDrone.Core/Indexers/Newznab/NewznabService.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; namespace NzbDrone.Core.Indexers.Newznab diff --git a/NzbDrone.Core/Jobs/Implementations/RenameSeasonJob.cs b/NzbDrone.Core/Jobs/Implementations/RenameSeasonJob.cs index b6553ff33..b7612161a 100644 --- a/NzbDrone.Core/Jobs/Implementations/RenameSeasonJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/RenameSeasonJob.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Model.Notification; @@ -14,16 +14,16 @@ namespace NzbDrone.Core.Jobs.Implementations { private readonly IMediaFileService _mediaFileService; private readonly ISeriesRepository _seriesRepository; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly IMoveEpisodeFiles _episodeFilesMover; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public RenameSeasonJob(IMediaFileService mediaFileService, ISeriesRepository seriesRepository, IEventAggregator eventAggregator, IMoveEpisodeFiles episodeFilesMover) + public RenameSeasonJob(IMediaFileService mediaFileService, ISeriesRepository seriesRepository, IMessageAggregator messageAggregator, IMoveEpisodeFiles episodeFilesMover) { _mediaFileService = mediaFileService; _seriesRepository = seriesRepository; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _episodeFilesMover = episodeFilesMover; } @@ -90,7 +90,7 @@ namespace NzbDrone.Core.Jobs.Implementations } //Start AfterRename - _eventAggregator.Publish(new SeriesRenamedEvent(series)); + _messageAggregator.Publish(new SeriesRenamedEvent(series)); notification.CurrentMessage = String.Format("Rename completed for {0} Season {1}", series.Title, options.SeasonNumber); } diff --git a/NzbDrone.Core/Jobs/Implementations/RenameSeriesJob.cs b/NzbDrone.Core/Jobs/Implementations/RenameSeriesJob.cs index d6ea87778..2543e51da 100644 --- a/NzbDrone.Core/Jobs/Implementations/RenameSeriesJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/RenameSeriesJob.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Model.Notification; @@ -14,16 +14,16 @@ namespace NzbDrone.Core.Jobs.Implementations { private readonly IMediaFileService _mediaFileService; private readonly ISeriesRepository _seriesRepository; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly IMoveEpisodeFiles _moveEpisodeFiles; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public RenameSeriesJob(IMediaFileService mediaFileService, ISeriesRepository seriesRepository, IEventAggregator eventAggregator, IMoveEpisodeFiles moveEpisodeFiles) + public RenameSeriesJob(IMediaFileService mediaFileService, ISeriesRepository seriesRepository, IMessageAggregator messageAggregator, IMoveEpisodeFiles moveEpisodeFiles) { _mediaFileService = mediaFileService; _seriesRepository = seriesRepository; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _moveEpisodeFiles = moveEpisodeFiles; } @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Jobs.Implementations //Start AfterRename - _eventAggregator.Publish(new SeriesRenamedEvent(series)); + _messageAggregator.Publish(new SeriesRenamedEvent(series)); notification.CurrentMessage = String.Format("Rename completed for {0}", series.Title); } diff --git a/NzbDrone.Core/Jobs/JobController.cs b/NzbDrone.Core/Jobs/JobController.cs index e56d38ca5..9dff23b99 100644 --- a/NzbDrone.Core/Jobs/JobController.cs +++ b/NzbDrone.Core/Jobs/JobController.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; diff --git a/NzbDrone.Core/Jobs/JobQueueItem.cs b/NzbDrone.Core/Jobs/JobQueueItem.cs index 53c274276..079c186c9 100644 --- a/NzbDrone.Core/Jobs/JobQueueItem.cs +++ b/NzbDrone.Core/Jobs/JobQueueItem.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; namespace NzbDrone.Core.Jobs { diff --git a/NzbDrone.Core/Jobs/JobRepository.cs b/NzbDrone.Core/Jobs/JobRepository.cs index a2234ed56..746ab3275 100644 --- a/NzbDrone.Core/Jobs/JobRepository.cs +++ b/NzbDrone.Core/Jobs/JobRepository.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Datastore; using NzbDrone.Core.Lifecycle; diff --git a/NzbDrone.Core/Jobs/JobTimer.cs b/NzbDrone.Core/Jobs/JobTimer.cs index c68e997e2..86022bdd9 100644 --- a/NzbDrone.Core/Jobs/JobTimer.cs +++ b/NzbDrone.Core/Jobs/JobTimer.cs @@ -1,5 +1,5 @@ using System.Timers; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; namespace NzbDrone.Core.Jobs diff --git a/NzbDrone.Core/Lifecycle/ApplicationShutdownRequested.cs b/NzbDrone.Core/Lifecycle/ApplicationShutdownRequested.cs index e5610058e..6c343546e 100644 --- a/NzbDrone.Core/Lifecycle/ApplicationShutdownRequested.cs +++ b/NzbDrone.Core/Lifecycle/ApplicationShutdownRequested.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Lifecycle { diff --git a/NzbDrone.Core/Lifecycle/ApplicationStartedEvent.cs b/NzbDrone.Core/Lifecycle/ApplicationStartedEvent.cs index 9ace92305..985986b05 100644 --- a/NzbDrone.Core/Lifecycle/ApplicationStartedEvent.cs +++ b/NzbDrone.Core/Lifecycle/ApplicationStartedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Lifecycle { diff --git a/NzbDrone.Core/MediaCover/MediaCoverService.cs b/NzbDrone.Core/MediaCover/MediaCoverService.cs index 5ea67cdf8..eb7942072 100644 --- a/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -2,7 +2,7 @@ using System.IO; using NLog; using NzbDrone.Common; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Tv; using NzbDrone.Core.Tv.Events; diff --git a/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs index 4079df116..522ced33d 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs @@ -3,7 +3,7 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Organizer; using NzbDrone.Core.Tv; @@ -21,17 +21,17 @@ namespace NzbDrone.Core.MediaFiles private readonly IEpisodeService _episodeService; private readonly IBuildFileNames _buildFileNames; private readonly IMediaFileService _mediaFileService; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly DiskProvider _diskProvider; private readonly Logger _logger; - public MoveEpisodeFiles(ISeriesRepository seriesRepository, IEpisodeService episodeService, IBuildFileNames buildFileNames, IMediaFileService mediaFileService, IEventAggregator eventAggregator, DiskProvider diskProvider, Logger logger) + public MoveEpisodeFiles(ISeriesRepository seriesRepository, IEpisodeService episodeService, IBuildFileNames buildFileNames, IMediaFileService mediaFileService, IMessageAggregator messageAggregator, DiskProvider diskProvider, Logger logger) { _seriesRepository = seriesRepository; _episodeService = episodeService; _buildFileNames = buildFileNames; _mediaFileService = mediaFileService; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _diskProvider = diskProvider; _logger = logger; } @@ -83,7 +83,7 @@ namespace NzbDrone.Core.MediaFiles if (newDownload) { - _eventAggregator.Publish(new EpisodeDownloadedEvent(parsedEpisodeInfo, series)); + _messageAggregator.Publish(new EpisodeDownloadedEvent(parsedEpisodeInfo, series)); } return episodeFile; diff --git a/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs b/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs index b0a5b91cd..09c3d0c4b 100644 --- a/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs +++ b/NzbDrone.Core/MediaFiles/Events/EpisodeDownloadedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Tv; diff --git a/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs b/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs index f332dfc7a..ba7326093 100644 --- a/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs +++ b/NzbDrone.Core/MediaFiles/Events/EpisodeFileAddedEvent.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Events { diff --git a/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs b/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs index 275635ea9..fe3a0d6b3 100644 --- a/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs +++ b/NzbDrone.Core/MediaFiles/Events/EpisodeFileDeletedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Events { diff --git a/NzbDrone.Core/MediaFiles/MediaFileService.cs b/NzbDrone.Core/MediaFiles/MediaFileService.cs index 3d0f97a03..76d5168be 100644 --- a/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Tv; @@ -24,23 +24,23 @@ namespace NzbDrone.Core.MediaFiles { private readonly IConfigService _configService; private readonly IEpisodeService _episodeService; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly Logger _logger; private readonly IMediaFileRepository _mediaFileRepository; - public MediaFileService(IMediaFileRepository mediaFileRepository, IConfigService configService, IEpisodeService episodeService, IEventAggregator eventAggregator, Logger logger) + public MediaFileService(IMediaFileRepository mediaFileRepository, IConfigService configService, IEpisodeService episodeService, IMessageAggregator messageAggregator, Logger logger) { _mediaFileRepository = mediaFileRepository; _configService = configService; _episodeService = episodeService; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _logger = logger; } public EpisodeFile Add(EpisodeFile episodeFile) { var addedFile = _mediaFileRepository.Insert(episodeFile); - _eventAggregator.Publish(new EpisodeFileAddedEvent(addedFile)); + _messageAggregator.Publish(new EpisodeFileAddedEvent(addedFile)); return addedFile; } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.MediaFiles public void Delete(EpisodeFile episodeFile) { _mediaFileRepository.Delete(episodeFile); - _eventAggregator.Publish(new EpisodeFileDeletedEvent(episodeFile)); + _messageAggregator.Publish(new EpisodeFileDeletedEvent(episodeFile)); } public bool Exists(string path) diff --git a/NzbDrone.Core/Providers/RecycleBinProvider.cs b/NzbDrone.Core/Providers/RecycleBinProvider.cs index 857ad77bd..4a7b0b952 100644 --- a/NzbDrone.Core/Providers/RecycleBinProvider.cs +++ b/NzbDrone.Core/Providers/RecycleBinProvider.cs @@ -3,7 +3,7 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.Tv.Events; diff --git a/NzbDrone.Core/Qualities/QualityProfileService.cs b/NzbDrone.Core/Qualities/QualityProfileService.cs index f09b11211..3dcab9aa7 100644 --- a/NzbDrone.Core/Qualities/QualityProfileService.cs +++ b/NzbDrone.Core/Qualities/QualityProfileService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; diff --git a/NzbDrone.Core/Qualities/QualitySizeService.cs b/NzbDrone.Core/Qualities/QualitySizeService.cs index fe31a8314..7d7a00830 100644 --- a/NzbDrone.Core/Qualities/QualitySizeService.cs +++ b/NzbDrone.Core/Qualities/QualitySizeService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Lifecycle; namespace NzbDrone.Core.Qualities diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index e7372de78..cd3f3e164 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using NLog; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles.Events; @@ -45,19 +45,19 @@ namespace NzbDrone.Core.Tv private readonly IProvideEpisodeInfo _episodeInfoProxy; private readonly ISeasonRepository _seasonRepository; private readonly IEpisodeRepository _episodeRepository; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly IConfigService _configService; private readonly ISeriesService _seriesService; private readonly Logger _logger; public EpisodeService(IProvideEpisodeInfo episodeInfoProxy, ISeasonRepository seasonRepository, - IEpisodeRepository episodeRepository, IEventAggregator eventAggregator, + IEpisodeRepository episodeRepository, IMessageAggregator messageAggregator, IConfigService configService, ISeriesService seriesService, Logger logger) { _episodeInfoProxy = episodeInfoProxy; _seasonRepository = seasonRepository; _episodeRepository = episodeRepository; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _configService = configService; _seriesService = seriesService; _logger = logger; @@ -211,12 +211,12 @@ namespace NzbDrone.Core.Tv if (newList.Any()) { - _eventAggregator.Publish(new EpisodeInfoAddedEvent(newList)); + _messageAggregator.Publish(new EpisodeInfoAddedEvent(newList)); } if (updateList.Any()) { - _eventAggregator.Publish(new EpisodeInfoUpdatedEvent(updateList)); + _messageAggregator.Publish(new EpisodeInfoUpdatedEvent(updateList)); } if (failCount != 0) diff --git a/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs b/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs index 36b52ca8c..8bca207ad 100644 --- a/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs +++ b/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Tv.Events { diff --git a/NzbDrone.Core/Tv/Events/EpisodeInfoUpdatedEvent.cs b/NzbDrone.Core/Tv/Events/EpisodeInfoUpdatedEvent.cs index fe2df05de..310e0d85d 100644 --- a/NzbDrone.Core/Tv/Events/EpisodeInfoUpdatedEvent.cs +++ b/NzbDrone.Core/Tv/Events/EpisodeInfoUpdatedEvent.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Tv.Events { diff --git a/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs b/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs index 3b91c75e7..7a6b513ca 100644 --- a/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs +++ b/NzbDrone.Core/Tv/Events/SeriesAddedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Tv.Events { diff --git a/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs b/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs index f9acfe79a..b9f752db2 100644 --- a/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs +++ b/NzbDrone.Core/Tv/Events/SeriesDeletedEvent.cs @@ -1,5 +1,5 @@ using System.Linq; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Tv.Events { diff --git a/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs b/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs index bc8118819..08cbe5c23 100644 --- a/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs +++ b/NzbDrone.Core/Tv/Events/SeriesUpdatedEvent.cs @@ -1,5 +1,5 @@ using System.Linq; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Tv.Events { diff --git a/NzbDrone.Core/Tv/SeasonService.cs b/NzbDrone.Core/Tv/SeasonService.cs index 06e341363..66b983686 100644 Binary files a/NzbDrone.Core/Tv/SeasonService.cs and b/NzbDrone.Core/Tv/SeasonService.cs differ diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index 4ffe0c736..a19d92c13 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -6,7 +6,7 @@ using Marr.Data; using NLog; using NzbDrone.Common; using NzbDrone.Common.EnsureThat; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.Datastore; using NzbDrone.Core.MetadataSource; @@ -41,19 +41,19 @@ namespace NzbDrone.Core.Tv private readonly ISeriesRepository _seriesRepository; private readonly IConfigService _configService; private readonly IProvideSeriesInfo _seriesInfoProxy; - private readonly IEventAggregator _eventAggregator; + private readonly IMessageAggregator _messageAggregator; private readonly IRootFolderService _rootFolderService; private readonly DiskProvider _diskProvider; private readonly Logger _logger; public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService, - IProvideSeriesInfo seriesInfoProxy, IEventAggregator eventAggregator, + IProvideSeriesInfo seriesInfoProxy, IMessageAggregator messageAggregator, IRootFolderService rootFolderService, DiskProvider diskProvider, Logger logger) { _seriesRepository = seriesRepository; _configService = configServiceService; _seriesInfoProxy = seriesInfoProxy; - _eventAggregator = eventAggregator; + _messageAggregator = messageAggregator; _rootFolderService = rootFolderService; _diskProvider = diskProvider; _logger = logger; @@ -83,7 +83,7 @@ namespace NzbDrone.Core.Tv //Todo: We need to get the UtcOffset from TVRage, since its not available from trakt - _eventAggregator.Publish(new SeriesUpdatedEvent(series)); + _messageAggregator.Publish(new SeriesUpdatedEvent(series)); return series; } @@ -114,7 +114,7 @@ namespace NzbDrone.Core.Tv newSeries.BacklogSetting = BacklogSettingType.Inherit; _seriesRepository.Insert(newSeries); - _eventAggregator.Publish(new SeriesAddedEvent(newSeries)); + _messageAggregator.Publish(new SeriesAddedEvent(newSeries)); return newSeries; } @@ -158,7 +158,7 @@ namespace NzbDrone.Core.Tv { var series = _seriesRepository.Get(seriesId); _seriesRepository.Delete(seriesId); - _eventAggregator.Publish(new SeriesDeletedEvent(series, deleteFiles)); + _messageAggregator.Publish(new SeriesDeletedEvent(series, deleteFiles)); } public List GetAllSeries() diff --git a/NzbDrone.Integration.Test/RootFolderIntegrationTest.cs b/NzbDrone.Integration.Test/RootFolderIntegrationTest.cs index fdfac5654..3ddae09c7 100644 --- a/NzbDrone.Integration.Test/RootFolderIntegrationTest.cs +++ b/NzbDrone.Integration.Test/RootFolderIntegrationTest.cs @@ -29,9 +29,32 @@ namespace NzbDrone.Integration.Test RootFolders.Delete(postResponse.Id); RootFolders.All().Should().BeEmpty(); - - } + } + [TestFixture] + public class QualityProfileIntegrationTest : IntegrationTest + { + [Test] + public void should_have_2_quality_profiles_initially() + { + RootFolders.All().Should().BeEmpty(); + + var rootFolder = new RootFolderResource + { + Path = Directory.GetCurrentDirectory() + }; + + var postResponse = RootFolders.Post(rootFolder); + + postResponse.Id.Should().NotBe(0); + postResponse.FreeSpace.Should().NotBe(0); + + RootFolders.All().Should().OnlyContain(c => c.Id == postResponse.Id); + + RootFolders.Delete(postResponse.Id); + + RootFolders.All().Should().BeEmpty(); + } } } \ No newline at end of file diff --git a/NzbDrone.Integration.Test/SeriesIntegrationTest.cs b/NzbDrone.Integration.Test/SeriesIntegrationTest.cs index e037fd22b..24404f907 100644 --- a/NzbDrone.Integration.Test/SeriesIntegrationTest.cs +++ b/NzbDrone.Integration.Test/SeriesIntegrationTest.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Integration.Test } [Test] - public void should_be_able_to_add_series() + public void should_be_able_to_add_and_delete_series() { var series = Series.Lookup("archer").First(); @@ -45,6 +45,10 @@ namespace NzbDrone.Integration.Test Series.Post(series); Series.All().Should().HaveCount(1); + + Series.Delete(series.Id); + + Series.All().Should().BeEmpty(); } } } \ No newline at end of file diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 799d6d058..9f4e90af2 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -5,7 +5,7 @@ using Moq; using NLog; using NUnit.Framework; using NzbDrone.Common; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Test.Common.AutoMoq; namespace NzbDrone.Test.Common @@ -122,12 +122,12 @@ namespace NzbDrone.Test.Common protected void VerifyEventPublished(Times times) where TEvent : IEvent { - Mocker.GetMock().Verify(c => c.Publish(It.IsAny()), times); + Mocker.GetMock().Verify(c => c.Publish(It.IsAny()), times); } protected void VerifyEventNotPublished() where TEvent : IEvent { - Mocker.GetMock().Verify(c => c.Publish(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Publish(It.IsAny()), Times.Never()); } } } diff --git a/NzbDrone/MainAppContainerBuilder.cs b/NzbDrone/MainAppContainerBuilder.cs index 4dbff5131..799f1bcb2 100644 --- a/NzbDrone/MainAppContainerBuilder.cs +++ b/NzbDrone/MainAppContainerBuilder.cs @@ -4,7 +4,7 @@ using NLog; using Nancy.Bootstrapper; using NzbDrone.Api; using NzbDrone.Common; -using NzbDrone.Common.Eventing; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore.Migration.Framework; using NzbDrone.Core.ExternalNotification; @@ -29,7 +29,7 @@ namespace NzbDrone { AutoRegisterImplementations(); - Container.Register().AsSingleton(); + Container.Register().AsSingleton(); Container.Register().AsSingleton(); Container.Register().AsSingleton(); Container.Register().AsSingleton();