renamed EventAggregator to MessageAggregator

pull/3113/head
Keivan Beigi 12 years ago
parent 3638d85314
commit 7ae9e79540

@ -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<IEventAggregator>().Publish(new ApplicationStartedEvent());
container.Resolve<IMessageAggregator>().Publish(new ApplicationStartedEvent());
ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve<ErrorPipeline>().HandleException);
}
@ -73,7 +73,7 @@ namespace NzbDrone.Api
public void Shutdown()
{
ApplicationContainer.Resolve<IEventAggregator>().Publish(new ApplicationShutdownRequested());
ApplicationContainer.Resolve<IMessageAggregator>().Publish(new ApplicationShutdownRequested());
}
}
}

@ -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

@ -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

@ -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<IEnumerable<IHandle>>().Should().NotBeEmpty();
MainAppContainerBuilder.BuildContainer().Resolve<IEnumerable<IProcessMessage>>().Should().NotBeEmpty();
}
[Test]

@ -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<IHandle<EventA>>();
var aggregator = new EventAggregator(TestLogger, () => new List<IHandle> { intHandler.Object });
var aggregator = new MessageAggregator(TestLogger, () => new List<IProcessMessage> { 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<IHandle<EventA>>();
var intHandler2 = new Mock<IHandle<EventA>>();
var aggregator = new EventAggregator(TestLogger, () => new List<IHandle> { intHandler1.Object, intHandler2.Object });
var aggregator = new MessageAggregator(TestLogger, () => new List<IProcessMessage> { 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<IHandle<EventA>>();
var bHandler = new Mock<IHandle<EventB>>();
var aggregator = new EventAggregator(TestLogger, () => new List<IHandle> { aHandler.Object, bHandler.Object });
var aggregator = new MessageAggregator(TestLogger, () => new List<IProcessMessage> { aHandler.Object, bHandler.Object });
aggregator.Publish(eventA);

@ -1,8 +0,0 @@
using System.Linq;
namespace NzbDrone.Common.Eventing
{
public interface IEvent
{
}
}

@ -0,0 +1,6 @@
namespace NzbDrone.Common.Messaging
{
public interface ICommand : IMessage
{
}
}

@ -0,0 +1,6 @@
namespace NzbDrone.Common.Messaging
{
public interface IEvent : IMessage
{
}
}

@ -1,12 +1,10 @@
using System.Linq;
namespace NzbDrone.Common.Eventing
namespace NzbDrone.Common.Messaging
{
/// <summary>
/// Denotes a class which can handle a particular type of message.
/// </summary>
/// <typeparam name = "TEvent">The type of message to handle.</typeparam>
public interface IHandle<TEvent> : IHandle where TEvent : IEvent
public interface IHandle<TEvent> : IProcessMessage where TEvent : IEvent
{
/// <summary>
/// Handles the message synchronously.
@ -19,7 +17,7 @@ namespace NzbDrone.Common.Eventing
/// Denotes a class which can handle a particular type of message.
/// </summary>
/// <typeparam name = "TEvent">The type of message to handle.</typeparam>
public interface IHandleAsync<TEvent> : IHandleAsync where TEvent : IEvent
public interface IHandleAsync<TEvent> : IProcessMessageAsync where TEvent : IEvent
{
/// <summary>
/// Handles the message asynchronously.
@ -27,14 +25,4 @@ namespace NzbDrone.Common.Eventing
/// <param name = "message">The message.</param>
void HandleAsync(TEvent message);
}
/// <summary>
/// A marker interface for classes that subscribe to messages.
/// </summary>
public interface IHandle { }
/// <summary>
/// A marker interface for classes that subscribe to messages.
/// </summary>
public interface IHandleAsync : IHandle { }
}

@ -0,0 +1,6 @@
namespace NzbDrone.Common.Messaging
{
public interface IMessage
{
}
}

@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Common.Eventing
namespace NzbDrone.Common.Messaging
{
/// <summary>
/// Enables loosely-coupled publication of events.
/// </summary>
public interface IEventAggregator
public interface IMessageAggregator
{
void Publish<TEvent>(TEvent message) where TEvent : IEvent;
void Execute<TCommand>(TCommand message) where TCommand : ICommand;
}
}

@ -0,0 +1,12 @@
namespace NzbDrone.Common.Messaging
{
/// <summary>
/// A marker interface for classes that subscribe to messages.
/// </summary>
public interface IProcessMessage { }
/// <summary>
/// A marker interface for classes that subscribe to messages.
/// </summary>
public interface IProcessMessageAsync : IProcessMessage { }
}

@ -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<IEnumerable<IHandle>> _handlers;
private readonly Func<IEnumerable<IProcessMessage>> _handlers;
public EventAggregator(Logger logger, Func<IEnumerable<IHandle>> handlers)
public MessageAggregator(Logger logger, Func<IEnumerable<IProcessMessage>> handlers)
{
_logger = logger;
_handlers = handlers;
@ -40,5 +40,10 @@ namespace NzbDrone.Common.Eventing
});
}
}
public void Execute<TCommand>(TCommand message) where TCommand : ICommand
{
throw new NotImplementedException();
}
}
}

@ -105,10 +105,13 @@
<Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" />
<Compile Include="EnsureThat\StringExtensions.cs" />
<Compile Include="EnsureThat\TypeParam.cs" />
<Compile Include="Eventing\EventAggregator.cs" />
<Compile Include="Eventing\IEvent.cs" />
<Compile Include="Eventing\IEventAggregator.cs" />
<Compile Include="Eventing\IHandle.cs" />
<Compile Include="Messaging\ICommand.cs" />
<Compile Include="Messaging\IMessage.cs" />
<Compile Include="Messaging\IProcessMessage.cs" />
<Compile Include="Messaging\MessageAggregator.cs" />
<Compile Include="Messaging\IEvent.cs" />
<Compile Include="Messaging\IMessageAggregator.cs" />
<Compile Include="Messaging\IHandle.cs" />
<Compile Include="Expansive\CircularReferenceException.cs" />
<Compile Include="Expansive\Expansive.cs" />
<Compile Include="Expansive\PatternStyle.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;

@ -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;

@ -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;

@ -1,5 +1,5 @@
using System.Linq;
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Download

@ -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;

@ -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;

@ -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;

@ -1,4 +1,4 @@
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Indexers
{

@ -1,5 +1,5 @@
using System;
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Indexers
{

@ -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

@ -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);
}

@ -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);
}

@ -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;

@ -1,5 +1,4 @@
using System;
using System.Linq;
namespace NzbDrone.Core.Jobs
{

@ -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;

@ -1,5 +1,5 @@
using System.Timers;
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Lifecycle;
namespace NzbDrone.Core.Jobs

@ -1,4 +1,4 @@
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Lifecycle
{

@ -1,4 +1,4 @@
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Lifecycle
{

@ -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;

@ -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;

@ -1,4 +1,4 @@
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;

@ -1,5 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Events
{

@ -1,4 +1,4 @@
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Events
{

@ -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)

@ -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;

@ -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;

@ -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

@ -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)

@ -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
{

@ -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
{

@ -1,4 +1,4 @@
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Tv.Events
{

@ -1,5 +1,5 @@
using System.Linq;
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Tv.Events
{

@ -1,5 +1,5 @@
using System.Linq;
using NzbDrone.Common.Eventing;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Tv.Events
{

Binary file not shown.

@ -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<Series> GetAllSeries()

@ -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();
}
}
}

@ -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();
}
}
}

@ -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<TEvent>(Times times) where TEvent : IEvent
{
Mocker.GetMock<IEventAggregator>().Verify(c => c.Publish(It.IsAny<TEvent>()), times);
Mocker.GetMock<IMessageAggregator>().Verify(c => c.Publish(It.IsAny<TEvent>()), times);
}
protected void VerifyEventNotPublished<TEvent>() where TEvent : IEvent
{
Mocker.GetMock<IEventAggregator>().Verify(c => c.Publish(It.IsAny<TEvent>()), Times.Never());
Mocker.GetMock<IMessageAggregator>().Verify(c => c.Publish(It.IsAny<TEvent>()), Times.Never());
}
}
}

@ -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<ExternalNotificationBase>();
Container.Register<IEventAggregator, EventAggregator>().AsSingleton();
Container.Register<IMessageAggregator, MessageAggregator>().AsSingleton();
Container.Register<INancyBootstrapper, NancyBootstrapper>().AsSingleton();
Container.Register<IAnnouncer, MigrationLogger>().AsSingleton();
Container.Register<Router>().AsSingleton();

Loading…
Cancel
Save