You've already forked Sonarr
							
							
				mirror of
				https://github.com/Sonarr/Sonarr.git
				synced 2025-10-31 00:07:55 +02:00 
			
		
		
		
	added test for command executed event
This commit is contained in:
		| @@ -67,10 +67,7 @@ | ||||
|     <Compile Include="EnsureTest\PathExtensionFixture.cs" /> | ||||
|     <Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" /> | ||||
|     <Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" /> | ||||
|     <Compile Include="MessagingTests\CommandBaseFixture.cs" /> | ||||
|     <Compile Include="MessagingTests\CommandExecutorFixture.cs" /> | ||||
|     <Compile Include="MessagingTests\MessageAggregatorEventTests.cs" /> | ||||
|     <Compile Include="MessagingTests\CommandEqualityComparerFixture.cs" /> | ||||
|     <Compile Include="ReflectionExtensions.cs" /> | ||||
|     <Compile Include="PathExtensionFixture.cs" /> | ||||
|     <Compile Include="DiskProviderTests\DiskProviderFixture.cs" /> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ using NzbDrone.Core.IndexerSearch; | ||||
| using NzbDrone.Core.MediaFiles.Commands; | ||||
| using NzbDrone.Core.Messaging.Commands; | ||||
| 
 | ||||
| namespace NzbDrone.Common.Test.MessagingTests | ||||
| namespace NzbDrone.Core.Test.Messaging.Commands | ||||
| { | ||||
|     [TestFixture] | ||||
|     public class CommandEqualityComparerFixture | ||||
| @@ -2,12 +2,13 @@ | ||||
| using System.Collections.Generic; | ||||
| using Moq; | ||||
| using NUnit.Framework; | ||||
| using NzbDrone.Core.Messaging; | ||||
| using NzbDrone.Common; | ||||
| using NzbDrone.Core.Messaging.Commands; | ||||
| using NzbDrone.Core.Messaging.Commands.Tracking; | ||||
| using NzbDrone.Core.Messaging.Events; | ||||
| using NzbDrone.Test.Common; | ||||
| 
 | ||||
| namespace NzbDrone.Common.Test.MessagingTests | ||||
| namespace NzbDrone.Core.Test.Messaging.Commands | ||||
| { | ||||
|     [TestFixture] | ||||
|     public class CommandExecutorFixture : TestBase<CommandExecutor> | ||||
| @@ -77,6 +78,29 @@ namespace NzbDrone.Common.Test.MessagingTests | ||||
| 
 | ||||
|             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 | ||||
| @@ -2,10 +2,10 @@ | ||||
| using NUnit.Framework; | ||||
| using NzbDrone.Core.Update.Commands; | ||||
| 
 | ||||
| namespace NzbDrone.Common.Test.MessagingTests | ||||
| namespace NzbDrone.Core.Test.Messaging.Commands | ||||
| { | ||||
|     [TestFixture] | ||||
|     public class CommandBaseFixture | ||||
|     public class CommandFixture | ||||
|     { | ||||
|         [Test] | ||||
|         public void default_values() | ||||
| @@ -15,6 +15,5 @@ namespace NzbDrone.Common.Test.MessagingTests | ||||
|             command.Id.Should().NotBe(0); | ||||
|             command.Name.Should().Be("ApplicationUpdate"); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @@ -147,6 +147,9 @@ | ||||
|     <Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" /> | ||||
|     <Compile Include="MediaFiles\MediaFileTableCleanupServiceFixture.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="NotificationTests\NotificationServiceFixture.cs" /> | ||||
|     <Compile Include="NotificationTests\Xbmc\GetJsonVersionFixture.cs" /> | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| using System; | ||||
| using System.Linq; | ||||
| using NzbDrone.Core.Datastore; | ||||
| using NzbDrone.Core.Messaging; | ||||
| using NzbDrone.Core.Messaging.Events; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -118,12 +118,13 @@ namespace NzbDrone.Core.Messaging.Commands | ||||
|             } | ||||
|             finally | ||||
|             { | ||||
|                 _eventAggregator.PublishEvent(new CommandUpdatedEvent(command)); | ||||
|                 _eventAggregator.PublishEvent(new CommandExecutedEvent(command)); | ||||
|  | ||||
|                 if (MappedDiagnosticsContext.Get("CommandId") == command.Id.ToString()) | ||||
|                 { | ||||
|                     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("")); | ||||
|   | ||||
| @@ -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/=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/TestFileAnalysis/TestClassSuffix/@EntryValue">Fixture</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/SilentCleanupProfile/@EntryValue">NzbDrone</s:String> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user