@ -1,4 +1,4 @@
using System ;
using System ;
using System.Linq ;
using System.Collections.Generic ;
using FluentAssertions ;
@ -19,6 +19,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected DelugeTorrent _downloading ;
protected DelugeTorrent _failed ;
protected DelugeTorrent _completed ;
protected DelugeTorrent _seeding ;
[SetUp]
public void Setup ( )
@ -75,7 +76,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Size = 1000 ,
BytesDownloaded = 1000 ,
Progress = 100.0 ,
DownloadPath = "somepath"
DownloadPath = "somepath" ,
IsAutoManaged = true ,
StopAtRatio = true ,
StopRatio = 1.0 ,
Ratio = 1.5
} ;
Mocker . GetMock < ITorrentFileInfoReader > ( )
@ -189,6 +194,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
PrepareClientToReturnCompletedItem ( ) ;
var item = Subject . GetItems ( ) . Single ( ) ;
VerifyCompleted ( item ) ;
item . CanBeRemoved . Should ( ) . BeTrue ( ) ;
item . CanMoveFiles . Should ( ) . BeTrue ( ) ;
}
[Test]
@ -248,11 +256,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
item . Status . Should ( ) . Be ( expectedItemStatus ) ;
}
[TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed , true )]
[TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading , true )]
[TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed , true )]
[TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed , true )]
public void GetItems_should_return_completed_item_as_downloadItemStatus ( string apiStatus , DownloadItemStatus expectedItemStatus , bool expectedReadOnly )
[TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed )]
[TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading )]
[TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed )]
[TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed )]
public void GetItems_should_return_completed_item_as_downloadItemStatus ( string apiStatus , DownloadItemStatus expectedItemStatus )
{
_completed . State = apiStatus ;
@ -261,24 +269,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
var item = Subject . GetItems ( ) . Single ( ) ;
item . Status . Should ( ) . Be ( expectedItemStatus ) ;
item . IsReadOnly . Should ( ) . Be ( expectedReadOnly ) ;
}
[Test]
public void GetItems_should_check_share_ratio_for_readonly ( )
[TestCase(0.5, false)]
[TestCase(1.01, true)]
public void GetItems_should_check_share_ratio_for_moveFiles_and_remove ( double ratio , bool canBeRemoved )
{
_completed . State = DelugeTorrentStatus . Paused ;
_completed . IsAutoManaged = true ;
_completed . StopAtRatio = true ;
_completed . StopRatio = 1.0 ;
_completed . Ratio = 1.01 ;
_completed . Ratio = ratio ;
PrepareClientToReturnCompletedItem ( ) ;
var item = Subject . GetItems ( ) . Single ( ) ;
item . Status . Should ( ) . Be ( DownloadItemStatus . Completed ) ;
item . IsReadOnly . Should ( ) . BeFalse ( ) ;
item . CanMoveFiles . Should ( ) . Be ( canBeRemoved ) ;
item . CanBeRemoved . Should ( ) . Be ( canBeRemoved ) ;
}
[Test]