@ -4,6 +4,7 @@ using NUnit.Framework;
using NzbDrone.Core.Books.Commands ;
using NzbDrone.Core.Books.Commands ;
using NzbDrone.Core.Download ;
using NzbDrone.Core.Download ;
using NzbDrone.Core.ImportLists ;
using NzbDrone.Core.ImportLists ;
using NzbDrone.Core.Indexers ;
using NzbDrone.Core.Messaging.Commands ;
using NzbDrone.Core.Messaging.Commands ;
using NzbDrone.Core.Test.Framework ;
using NzbDrone.Core.Test.Framework ;
using NzbDrone.Core.Update.Commands ;
using NzbDrone.Core.Update.Commands ;
@ -25,6 +26,18 @@ namespace NzbDrone.Core.Test.Messaging.Commands
Subject . Add ( commandModel ) ;
Subject . Add ( commandModel ) ;
}
}
private void GivenLongRunningCommand ( )
{
var commandModel = Builder < CommandModel >
. CreateNew ( )
. With ( c = > c . Name = "RssSync" )
. With ( c = > c . Body = new RssSyncCommand ( ) )
. With ( c = > c . Status = CommandStatus . Started )
. Build ( ) ;
Subject . Add ( commandModel ) ;
}
private void GivenStartedTypeExclusiveCommand ( )
private void GivenStartedTypeExclusiveCommand ( )
{
{
var commandModel = Builder < CommandModel >
var commandModel = Builder < CommandModel >
@ -85,6 +98,24 @@ namespace NzbDrone.Core.Test.Messaging.Commands
command . Should ( ) . BeNull ( ) ;
command . Should ( ) . BeNull ( ) ;
}
}
[Test]
public void should_not_return_exclusive_command_if_long_running_command_running ( )
{
GivenLongRunningCommand ( ) ;
var newCommandModel = Builder < CommandModel >
. CreateNew ( )
. With ( c = > c . Name = "ApplicationUpdate" )
. With ( c = > c . Body = new ApplicationUpdateCommand ( ) )
. Build ( ) ;
Subject . Add ( newCommandModel ) ;
Subject . TryGet ( out var command ) ;
command . Should ( ) . BeNull ( ) ;
}
[Test]
[Test]
public void should_not_return_type_exclusive_command_if_another_and_disk_access_command_running ( )
public void should_not_return_type_exclusive_command_if_another_and_disk_access_command_running ( )
{
{