@ -20,16 +20,16 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
protected DownloadStationSettings _settings ;
protected DownloadStationT orrent _queued ;
protected DownloadStationT orrent _downloading ;
protected DownloadStationT orrent _failed ;
protected DownloadStationT orrent _completed ;
protected DownloadStationT orrent _seeding ;
protected DownloadStationT orrent _magnet ;
protected DownloadStationT orrent _singleFile ;
protected DownloadStationT orrent _multipleFiles ;
protected DownloadStationT orrent _singleFileCompleted ;
protected DownloadStationT orrent _multipleFilesCompleted ;
protected DownloadStationT ask _queued ;
protected DownloadStationT ask _downloading ;
protected DownloadStationT ask _failed ;
protected DownloadStationT ask _completed ;
protected DownloadStationT ask _seeding ;
protected DownloadStationT ask _magnet ;
protected DownloadStationT ask _singleFile ;
protected DownloadStationT ask _multipleFiles ;
protected DownloadStationT ask _singleFileCompleted ;
protected DownloadStationT ask _multipleFilesCompleted ;
protected string _serialNumber = "SERIALNUMBER" ;
protected string _category = "sonarr" ;
@ -55,15 +55,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Subject . Definition = new DownloadClientDefinition ( ) ;
Subject . Definition . Settings = _settings ;
_queued = new DownloadStationT orrent ( )
_queued = new DownloadStationT ask ( )
{
Id = "id1" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Waiting ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -78,15 +78,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_completed = new DownloadStationT orrent ( )
_completed = new DownloadStationT ask ( )
{
Id = "id2" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Finished ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -101,15 +101,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_seeding = new DownloadStationT orrent ( )
_seeding = new DownloadStationT ask ( )
{
Id = "id2" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Seeding ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -124,15 +124,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_downloading = new DownloadStationT orrent ( )
_downloading = new DownloadStationT ask ( )
{
Id = "id3" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Downloading ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -147,15 +147,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_failed = new DownloadStationT orrent ( )
_failed = new DownloadStationT ask ( )
{
Id = "id4" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Error ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -170,15 +170,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_singleFile = new DownloadStationT orrent ( )
_singleFile = new DownloadStationT ask ( )
{
Id = "id5" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Seeding ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "a.mkv" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -193,15 +193,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_multipleFiles = new DownloadStationT orrent ( )
_multipleFiles = new DownloadStationT ask ( )
{
Id = "id6" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Seeding ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -216,15 +216,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_singleFileCompleted = new DownloadStationT orrent ( )
_singleFileCompleted = new DownloadStationT ask ( )
{
Id = "id6" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Finished ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "a.mkv" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -239,15 +239,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
} ;
_multipleFilesCompleted = new DownloadStationT orrent ( )
_multipleFilesCompleted = new DownloadStationT ask ( )
{
Id = "id6" ,
Size = 1000 ,
Status = DownloadStationTaskStatus . Finished ,
Type = DownloadStationTaskType . BT ,
Type = DownloadStationTaskType . BT .ToString ( ) ,
Username = "admin" ,
Title = "title" ,
Additional = new DownloadStationT orrent Additional
Additional = new DownloadStationT ask Additional
{
Detail = new Dictionary < string , string >
{
@ -304,21 +304,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_settings . TvDirectory = _tvDirectory ;
}
protected virtual void GivenT orrents( List < DownloadStationTorrent > torrents )
protected virtual void GivenT asks( List < DownloadStationTask > torrents )
{
if ( torrents = = null )
{
torrents = new List < DownloadStationT orrent > ( ) ;
torrents = new List < DownloadStationT ask > ( ) ;
}
Mocker . GetMock < IDownloadStationProxy > ( )
. Setup ( s = > s . GetT orrent s( It . IsAny < DownloadStationSettings > ( ) ) )
. Setup ( s = > s . GetT ask s( It . IsAny < DownloadStationSettings > ( ) ) )
. Returns ( torrents ) ;
}
protected void PrepareClientToReturnQueuedItem ( )
{
GivenT orrents( new List < DownloadStationTorrent >
GivenT asks( new List < DownloadStationTask >
{
_queued
} ) ;
@ -331,11 +331,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
. Returns < HttpRequest > ( r = > new HttpResponse ( r , new HttpHeader ( ) , new byte [ 1000 ] ) ) ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Setup ( s = > s . AddT orrent FromUrl( It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < DownloadStationSettings > ( ) ) )
. Setup ( s = > s . AddT ask FromUrl( It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < DownloadStationSettings > ( ) ) )
. Callback ( PrepareClientToReturnQueuedItem ) ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Setup ( s = > s . AddT orrent FromData( It . IsAny < byte [ ] > ( ) , It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < DownloadStationSettings > ( ) ) )
. Setup ( s = > s . AddT ask FromData( It . IsAny < byte [ ] > ( ) , It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < DownloadStationSettings > ( ) ) )
. Callback ( PrepareClientToReturnQueuedItem ) ;
}
@ -350,10 +350,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
protected int GivenAllKindOfTasks ( )
{
var tasks = new List < DownloadStationT orrent > ( ) { _queued , _completed , _failed , _downloading , _seeding } ;
var tasks = new List < DownloadStationT ask > ( ) { _queued , _completed , _failed , _downloading , _seeding } ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Setup ( d = > d . GetT orrent s( _settings ) )
. Setup ( d = > d . GetT ask s( _settings ) )
. Returns ( tasks ) ;
return tasks . Count ;
@ -373,7 +373,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
id . Should ( ) . NotBeNullOrEmpty ( ) ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Verify ( v = > v . AddT orrent FromUrl( It . IsAny < string > ( ) , _tvDirectory , It . IsAny < DownloadStationSettings > ( ) ) , Times . Once ( ) ) ;
. Verify ( v = > v . AddT ask FromUrl( It . IsAny < string > ( ) , _tvDirectory , It . IsAny < DownloadStationSettings > ( ) ) , Times . Once ( ) ) ;
}
[Test]
@ -390,7 +390,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
id . Should ( ) . NotBeNullOrEmpty ( ) ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Verify ( v = > v . AddT orrent FromUrl( It . IsAny < string > ( ) , $"{_defaultDestination}/{_category}" , It . IsAny < DownloadStationSettings > ( ) ) , Times . Once ( ) ) ;
. Verify ( v = > v . AddT ask FromUrl( It . IsAny < string > ( ) , $"{_defaultDestination}/{_category}" , It . IsAny < DownloadStationSettings > ( ) ) , Times . Once ( ) ) ;
}
[Test]
@ -406,7 +406,29 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
id . Should ( ) . NotBeNullOrEmpty ( ) ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Verify ( v = > v . AddTorrentFromUrl ( It . IsAny < string > ( ) , null , It . IsAny < DownloadStationSettings > ( ) ) , Times . Once ( ) ) ;
. Verify ( v = > v . AddTaskFromUrl ( It . IsAny < string > ( ) , null , It . IsAny < DownloadStationSettings > ( ) ) , Times . Once ( ) ) ;
}
[Test]
public void GetItems_should_return_empty_list_if_no_tasks_available ( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenTasks ( new List < DownloadStationTask > ( ) ) ;
Subject . GetItems ( ) . Should ( ) . BeEmpty ( ) ;
}
[Test]
public void GetItems_should_return_ignore_tasks_of_unknown_type ( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenTasks ( new List < DownloadStationTask > { _completed } ) ;
_completed . Type = "ipfs" ;
Subject . GetItems ( ) . Should ( ) . BeEmpty ( ) ;
}
[Test]
@ -416,7 +438,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent > { _completed } ) ;
GivenT asks( new List < DownloadStationTask > { _completed } ) ;
Subject . GetItems ( ) . Should ( ) . BeEmpty ( ) ;
}
@ -450,7 +472,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void Download_should_throw_and_not_add_t orrent _if_cannot_get_serial_number( )
public void Download_should_throw_and_not_add_t ask _if_cannot_get_serial_number( )
{
var remoteEpisode = CreateRemoteEpisode ( ) ;
@ -461,16 +483,16 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Assert . Throws ( Is . InstanceOf < Exception > ( ) , ( ) = > Subject . Download ( remoteEpisode ) ) ;
Mocker . GetMock < IDownloadStationProxy > ( )
. Verify ( v = > v . AddT orrent FromUrl( It . IsAny < string > ( ) , null , _settings ) , Times . Never ( ) ) ;
. Verify ( v = > v . AddT ask FromUrl( It . IsAny < string > ( ) , null , _settings ) , Times . Never ( ) ) ;
}
[Test]
public void GetItems_should_set_outputPath_to_base_folder_when_single_file_non_finished_t orrent ( )
public void GetItems_should_set_outputPath_to_base_folder_when_single_file_non_finished_t asks ( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent > ( ) { _singleFile } ) ;
GivenT asks( new List < DownloadStationTask > ( ) { _singleFile } ) ;
var items = Subject . GetItems ( ) ;
@ -479,12 +501,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void GetItems_should_set_outputPath_to_torrent_folder_when_multiple_files_non_finished_t orrent ( )
public void GetItems_should_set_outputPath_to_torrent_folder_when_multiple_files_non_finished_t asks ( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent > ( ) { _multipleFiles } ) ;
GivenT asks( new List < DownloadStationTask > ( ) { _multipleFiles } ) ;
var items = Subject . GetItems ( ) ;
@ -493,12 +515,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void GetItems_should_set_outputPath_to_base_folder_when_single_file_finished_t orrent ( )
public void GetItems_should_set_outputPath_to_base_folder_when_single_file_finished_t asks ( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent > ( ) { _singleFileCompleted } ) ;
GivenT asks( new List < DownloadStationTask > ( ) { _singleFileCompleted } ) ;
var items = Subject . GetItems ( ) ;
@ -507,12 +529,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void GetItems_should_set_outputPath_to_torrent_folder_when_multiple_files_finished_t orrent ( )
public void GetItems_should_set_outputPath_to_torrent_folder_when_multiple_files_finished_t asks ( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent > ( ) { _multipleFilesCompleted } ) ;
GivenT asks( new List < DownloadStationTask > ( ) { _multipleFilesCompleted } ) ;
var items = Subject . GetItems ( ) ;
@ -521,12 +543,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void GetItems_should_not_map_outputpath_for_queued_or_downloading_t orrent s( )
public void GetItems_should_not_map_outputpath_for_queued_or_downloading_t ask s( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent >
GivenT asks( new List < DownloadStationTask >
{
_queued , _downloading
} ) ;
@ -538,12 +560,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void GetItems_should_map_outputpath_for_completed_or_failed_t orrent s( )
public void GetItems_should_map_outputpath_for_completed_or_failed_t ask s( )
{
GivenSerialNumber ( ) ;
GivenSharedFolder ( ) ;
GivenT orrents( new List < DownloadStationTorrent >
GivenT asks( new List < DownloadStationTask >
{
_completed , _failed , _seeding
} ) ;
@ -565,7 +587,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_queued . Status = apiStatus ;
GivenT orrents( new List < DownloadStationTorrent > ( ) { _queued } ) ;
GivenT asks( new List < DownloadStationTask > ( ) { _queued } ) ;
var items = Subject . GetItems ( ) ;
@ -589,7 +611,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_queued . Status = apiStatus ;
GivenT orrents( new List < DownloadStationTorrent > ( ) { _queued } ) ;
GivenT asks( new List < DownloadStationTask > ( ) { _queued } ) ;
var items = Subject . GetItems ( ) ;
items . Should ( ) . HaveCount ( 1 ) ;
@ -597,4 +619,4 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
items . First ( ) . Status . Should ( ) . Be ( expectedItemStatus ) ;
}
}
}
}