updated CommandExecutedEvent to be handled sync.

pull/30/head
kay.one 11 years ago
parent eb7dda0629
commit 48c06de098

@ -67,7 +67,6 @@
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
<Compile Include="MessagingTests\MessageAggregatorEventTests.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="PathExtensionFixture.cs" />
<Compile Include="DiskProviderTests\DiskProviderFixture.cs" />

@ -4,15 +4,15 @@ using System.Threading;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test.MessagingTests
namespace NzbDrone.Core.Test.Messaging.Events
{
[TestFixture]
public class MessageAggregatorEventTests : TestBase<EventAggregator>
public class EventAggregatorFixture : TestBase<EventAggregator>
{
private Mock<IHandle<EventA>> HandlerA1;
private Mock<IHandle<EventA>> HandlerA2;
@ -119,11 +119,11 @@ namespace NzbDrone.Common.Test.MessagingTests
AsyncHandlerA1.Setup(c => c.HandleAsync(It.IsAny<EventA>()))
.Callback<EventA>(c =>
{
var id = counter.Start();
Thread.Sleep(1000);
counter.Stop(id);
});
{
var id = counter.Start();
Thread.Sleep(1000);
counter.Stop(id);
});
Subject.PublishEvent(eventA);
@ -143,5 +143,4 @@ namespace NzbDrone.Common.Test.MessagingTests
{
}
}

@ -150,6 +150,7 @@
<Compile Include="Messaging\Commands\CommandEqualityComparerFixture.cs" />
<Compile Include="Messaging\Commands\CommandExecutorFixture.cs" />
<Compile Include="Messaging\Commands\CommandFixture.cs" />
<Compile Include="Messaging\Events\EventAggregatorFixture.cs" />
<Compile Include="MetadataSourceTests\TraktProxyFixture.cs" />
<Compile Include="NotificationTests\NotificationServiceFixture.cs" />
<Compile Include="NotificationTests\Xbmc\GetJsonVersionFixture.cs" />

@ -6,7 +6,6 @@ using NLog.Targets;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Instrumentation

@ -3,7 +3,6 @@ using System.Threading;
using System.Threading.Tasks;
using NLog;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using Timer = System.Timers.Timer;

@ -9,7 +9,6 @@ using NzbDrone.Core.Indexers;
using NzbDrone.Core.Instrumentation.Commands;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Commands.Tracking;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Providers;
@ -23,7 +22,7 @@ namespace NzbDrone.Core.Jobs
IList<ScheduledTask> GetPending();
}
public class TaskManager : ITaskManager, IHandle<ApplicationStartedEvent>, IHandleAsync<CommandExecutedEvent>, IHandleAsync<ConfigSavedEvent>
public class TaskManager : ITaskManager, IHandle<ApplicationStartedEvent>, IHandle<CommandExecutedEvent>, IHandleAsync<ConfigSavedEvent>
{
private readonly IScheduledTaskRepository _scheduledTaskRepository;
private readonly IConfigService _configService;
@ -79,7 +78,7 @@ namespace NzbDrone.Core.Jobs
}
}
public void HandleAsync(CommandExecutedEvent message)
public void Handle(CommandExecutedEvent message)
{
var scheduledTask = _scheduledTaskRepository.All().SingleOrDefault(c => c.TypeName == message.Command.GetType().FullName);
@ -97,4 +96,4 @@ namespace NzbDrone.Core.Jobs
_scheduledTaskRepository.Update(rss);
}
}
}
}

Loading…
Cancel
Save