mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
added test for command executed event
This commit is contained in:
parent
e2e787261d
commit
634cc32ad8
@ -67,10 +67,7 @@
|
|||||||
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
|
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
|
||||||
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
||||||
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
|
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
|
||||||
<Compile Include="MessagingTests\CommandBaseFixture.cs" />
|
|
||||||
<Compile Include="MessagingTests\CommandExecutorFixture.cs" />
|
|
||||||
<Compile Include="MessagingTests\MessageAggregatorEventTests.cs" />
|
<Compile Include="MessagingTests\MessageAggregatorEventTests.cs" />
|
||||||
<Compile Include="MessagingTests\CommandEqualityComparerFixture.cs" />
|
|
||||||
<Compile Include="ReflectionExtensions.cs" />
|
<Compile Include="ReflectionExtensions.cs" />
|
||||||
<Compile Include="PathExtensionFixture.cs" />
|
<Compile Include="PathExtensionFixture.cs" />
|
||||||
<Compile Include="DiskProviderTests\DiskProviderFixture.cs" />
|
<Compile Include="DiskProviderTests\DiskProviderFixture.cs" />
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
using NzbDrone.Core.MediaFiles.Commands;
|
using NzbDrone.Core.MediaFiles.Commands;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Common.Test.MessagingTests
|
namespace NzbDrone.Core.Test.Messaging.Commands
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CommandEqualityComparerFixture
|
public class CommandEqualityComparerFixture
|
@ -2,12 +2,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Messaging;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Commands.Tracking;
|
using NzbDrone.Core.Messaging.Commands.Tracking;
|
||||||
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Common.Test.MessagingTests
|
namespace NzbDrone.Core.Test.Messaging.Commands
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CommandExecutorFixture : TestBase<CommandExecutor>
|
public class CommandExecutorFixture : TestBase<CommandExecutor>
|
||||||
@ -77,6 +78,29 @@ public void broken_executor_should_throw_the_exception()
|
|||||||
|
|
||||||
Assert.Throws<NotImplementedException>(() => Subject.PublishCommand(commandA));
|
Assert.Throws<NotImplementedException>(() => Subject.PublishCommand(commandA));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void broken_executor_should_publish_executed_event()
|
||||||
|
{
|
||||||
|
var commandA = new CommandA();
|
||||||
|
|
||||||
|
_executorA.Setup(c => c.Execute(It.IsAny<CommandA>()))
|
||||||
|
.Throws(new NotImplementedException());
|
||||||
|
|
||||||
|
Assert.Throws<NotImplementedException>(() => Subject.PublishCommand(commandA));
|
||||||
|
|
||||||
|
VerifyEventPublished<CommandExecutedEvent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_publish_executed_event_on_success()
|
||||||
|
{
|
||||||
|
var commandA = new CommandA();
|
||||||
|
Subject.PublishCommand(commandA);
|
||||||
|
|
||||||
|
VerifyEventPublished<CommandExecutedEvent>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CommandA : Command
|
public class CommandA : Command
|
@ -2,10 +2,10 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Update.Commands;
|
using NzbDrone.Core.Update.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Common.Test.MessagingTests
|
namespace NzbDrone.Core.Test.Messaging.Commands
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CommandBaseFixture
|
public class CommandFixture
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void default_values()
|
public void default_values()
|
||||||
@ -15,6 +15,5 @@ public void default_values()
|
|||||||
command.Id.Should().NotBe(0);
|
command.Id.Should().NotBe(0);
|
||||||
command.Name.Should().Be("ApplicationUpdate");
|
command.Name.Should().Be("ApplicationUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -147,6 +147,9 @@
|
|||||||
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
|
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
|
||||||
<Compile Include="MediaFiles\MediaFileTableCleanupServiceFixture.cs" />
|
<Compile Include="MediaFiles\MediaFileTableCleanupServiceFixture.cs" />
|
||||||
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
|
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
|
||||||
|
<Compile Include="Messaging\Commands\CommandEqualityComparerFixture.cs" />
|
||||||
|
<Compile Include="Messaging\Commands\CommandExecutorFixture.cs" />
|
||||||
|
<Compile Include="Messaging\Commands\CommandFixture.cs" />
|
||||||
<Compile Include="MetadataSourceTests\TraktProxyFixture.cs" />
|
<Compile Include="MetadataSourceTests\TraktProxyFixture.cs" />
|
||||||
<Compile Include="NotificationTests\NotificationServiceFixture.cs" />
|
<Compile Include="NotificationTests\NotificationServiceFixture.cs" />
|
||||||
<Compile Include="NotificationTests\Xbmc\GetJsonVersionFixture.cs" />
|
<Compile Include="NotificationTests\Xbmc\GetJsonVersionFixture.cs" />
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Messaging;
|
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,12 +118,13 @@ private void ExecuteCommand<TCommand>(Command command) where TCommand : Command
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
_eventAggregator.PublishEvent(new CommandUpdatedEvent(command));
|
||||||
|
_eventAggregator.PublishEvent(new CommandExecutedEvent(command));
|
||||||
|
|
||||||
if (MappedDiagnosticsContext.Get("CommandId") == command.Id.ToString())
|
if (MappedDiagnosticsContext.Get("CommandId") == command.Id.ToString())
|
||||||
{
|
{
|
||||||
MappedDiagnosticsContext.Remove("CommandId");
|
MappedDiagnosticsContext.Remove("CommandId");
|
||||||
}
|
}
|
||||||
_eventAggregator.PublishEvent(new CommandUpdatedEvent(command));
|
|
||||||
_eventAggregator.PublishEvent(new CommandExecutedEvent(command));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Trace("{0} <- {1} [{2}]", command.GetType().Name, handler.GetType().Name, command.Runtime.ToString(""));
|
_logger.Trace("{0} <- {1} [{2}]", command.GetType().Name, handler.GetType().Name, command.Runtime.ToString(""));
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue">WARNING</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue">WARNING</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedParameter_002ELocal/@EntryIndexedValue">WARNING</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedParameter_002ELocal/@EntryIndexedValue">WARNING</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">HINT</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">HINT</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/TestFileAnalysis/TestClassSuffix/@EntryValue">Fixture</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/TestFileAnalysis/TestProjectToCodeProjectNameSpaceRegEx/@EntryValue">^(.*)\.Test(\..*)$</s:String>
|
<s:String x:Key="/Default/CodeInspection/TestFileAnalysis/TestProjectToCodeProjectNameSpaceRegEx/@EntryValue">^(.*)\.Test(\..*)$</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=NzbDrone/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="NzbDrone"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_EXCEPT_SIMPLE_TYPES</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSUpdateFileHeader>True</CSUpdateFileHeader><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReorderTypeMembers>True</CSReorderTypeMembers><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags></Profile></s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=NzbDrone/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="NzbDrone"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_EXCEPT_SIMPLE_TYPES</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSUpdateFileHeader>True</CSUpdateFileHeader><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReorderTypeMembers>True</CSReorderTypeMembers><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags></Profile></s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">NzbDrone</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">NzbDrone</s:String>
|
||||||
|
Loading…
Reference in New Issue
Block a user