@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
. Build ( ) ;
}
private RemoteEpisode GetRemoteEpisode ( List < Episode > episodes , QualityModel quality )
private RemoteEpisode GetRemoteEpisode ( List < Episode > episodes , QualityModel quality , int Age = 0 , long size = 0 )
{
var remoteEpisode = new RemoteEpisode ( ) ;
remoteEpisode . ParsedEpisodeInfo = new ParsedEpisodeInfo ( ) ;
@ -33,7 +33,8 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
remoteEpisode . Episodes . AddRange ( episodes ) ;
remoteEpisode . Report = new ReportInfo ( ) ;
remoteEpisode . Report . Age = 0 ;
remoteEpisode . Report . Age = Age ;
remoteEpisode . Report . Size = size ;
return remoteEpisode ;
}
@ -77,7 +78,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
}
[Test]
public void should_order_by_lowest_ episode_number ( )
public void should_order_by_lowest_ number_of_episodes ( )
{
var remoteEpisode1 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 2 ) } , new QualityModel ( Quality . HDTV720p ) ) ;
var remoteEpisode2 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) ) ;
@ -91,7 +92,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
}
[Test]
public void should_order_by_lowest_ episode_number _with_multiple_episodes( )
public void should_order_by_lowest_ number_of_episodes _with_multiple_episodes( )
{
var remoteEpisode1 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 2 ) , GetEpisode ( 3 ) } , new QualityModel ( Quality . HDTV720p ) ) ;
var remoteEpisode2 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) , GetEpisode ( 2 ) } , new QualityModel ( Quality . HDTV720p ) ) ;
@ -104,21 +105,38 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
qualifiedReports . First ( ) . RemoteEpisode . Episodes . First ( ) . EpisodeNumber . Should ( ) . Be ( 1 ) ;
}
[Test]
public void should_order_by_smallest_rounded_to_200mb_then_age ( )
{
var remoteEpisodeSd = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . SDTV ) , size : 100. Megabytes ( ) , Age : 1 ) ;
var remoteEpisodeHdSmallOld = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) , size : 1200. Megabytes ( ) , Age : 1000 ) ;
var remoteEpisodeHdSmallYounge = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) , size : 1250. Megabytes ( ) , Age : 10 ) ;
var remoteEpisodeHdLargeYounge = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) , size : 3000. Megabytes ( ) , Age : 1 ) ;
var decisions = new List < DownloadDecision > ( ) ;
decisions . Add ( new DownloadDecision ( remoteEpisodeSd ) ) ;
decisions . Add ( new DownloadDecision ( remoteEpisodeHdSmallOld ) ) ;
decisions . Add ( new DownloadDecision ( remoteEpisodeHdSmallYounge ) ) ;
decisions . Add ( new DownloadDecision ( remoteEpisodeHdLargeYounge ) ) ;
var qualifiedReports = Subject . GetQualifiedReports ( decisions ) ;
qualifiedReports . First ( ) . RemoteEpisode . Should ( ) . Be ( remoteEpisodeHdSmallYounge ) ;
}
[Test]
public void should_order_by_youngest ( )
{
var remoteEpisode1 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) ) ;
var remoteEpisode2 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) ) ;
var remoteEpisode1 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) , Age : 10 );
var remoteEpisode2 = GetRemoteEpisode ( new List < Episode > { GetEpisode ( 1 ) } , new QualityModel ( Quality . HDTV720p ) , Age : 5 );
remoteEpisode1 . Report . Age = 10 ;
remoteEpisode2 . Report . Age = 5 ;
var decisions = new List < DownloadDecision > ( ) ;
decisions . Add ( new DownloadDecision ( remoteEpisode1 ) ) ;
decisions . Add ( new DownloadDecision ( remoteEpisode2 ) ) ;
var qualifiedReports = Subject . GetQualifiedReports ( decisions ) ;
qualifiedReports . First ( ) . RemoteEpisode . Report . Age . Should ( ) . Be ( 5 ) ;
qualifiedReports . First ( ) . RemoteEpisode . Should( ) . Be ( remoteEpisode2 ) ;
}
}
}