@ -158,41 +158,72 @@ namespace NzbDrone.Core.Test.ProviderTests
var episodes = Builder < Episode > . CreateListOfSize ( 10 ) . Build ( ) ;
var historyEpisode = episodes [ 6 ] ;
var history0 = Builder < History > . CreateNew ( )
. With ( h = > h . Quality = QualityTypes . DVD )
. With ( h = > h . IsProper = true )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. Build ( ) ;
var history = Builder < History >
. CreateListOfSize ( 5 )
. All ( )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. With ( h = > h . SeriesId = historyEpisode . SeriesId )
. TheFirst ( 1 )
. With ( h = > h . Quality = QualityTypes . DVD )
. With ( h = > h . IsProper = true )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . Bluray720p )
. With ( h = > h . IsProper = false )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . Bluray720p )
. With ( h = > h . IsProper = true )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . Bluray720p )
. With ( h = > h . IsProper = false )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . SDTV )
. With ( h = > h . IsProper = true )
. Build ( ) ;
Db . InsertMany ( history ) ;
Db . InsertMany ( episodes ) ;
var history1 = Builder < History > . CreateNew ( )
. With ( h = > h . Quality = QualityTypes . Bluray720p )
. With ( h = > h . IsProper = false )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. Build ( ) ;
//Act
var result = Mocker . Resolve < HistoryProvider > ( )
. GetBestQualityInHistory ( historyEpisode . SeriesId , historyEpisode . SeasonNumber , historyEpisode . EpisodeNumber ) ;
var history2 = Builder < History > . CreateNew ( )
. With ( h = > h . Quality = QualityTypes . Bluray720p )
. With ( h = > h . IsProper = true )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. Build ( ) ;
//Assert
result . Should ( ) . NotBeNull ( ) ;
result . Quality . Should ( ) . Be ( QualityTypes . Bluray720p ) ;
result . Proper . Should ( ) . BeTrue ( ) ;
}
var history3 = Builder < History > . CreateNew ( )
. With ( h = > h . Quality = QualityTypes . Bluray720p )
. With ( h = > h . IsProper = false )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. Build ( ) ;
[Test]
public void GetBestQualityInHistory_should_return_highest_weighted_result ( )
{
WithRealDb ( ) ;
var history4 = Builder < History > . CreateNew ( )
. With ( h = > h . Quality = QualityTypes . SDTV )
. With ( h = > h . IsProper = true )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. Build ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 10 ) . Build ( ) ;
var historyEpisode = episodes [ 6 ] ;
Db . Insert ( history0 ) ;
Db . Insert ( history1 ) ;
Db . Insert ( history2 ) ;
Db . Insert ( history2 ) ;
Db . Insert ( history4 ) ;
var history = Builder < History >
. CreateListOfSize ( 5 )
. All ( )
. With ( h = > h . EpisodeId = historyEpisode . EpisodeId )
. With ( h = > h . SeriesId = historyEpisode . SeriesId )
. TheFirst ( 1 )
. With ( h = > h . Quality = QualityTypes . DVD )
. With ( h = > h . IsProper = true )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . WEBDL720p )
. With ( h = > h . IsProper = false )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . WEBDL720p )
. With ( h = > h . IsProper = true )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . WEBDL1080p )
. With ( h = > h . IsProper = false )
. TheNext ( 1 )
. With ( h = > h . Quality = QualityTypes . SDTV )
. With ( h = > h . IsProper = true )
. Build ( ) ;
Db . InsertMany ( history ) ;
Db . InsertMany ( episodes ) ;
//Act
@ -201,8 +232,8 @@ namespace NzbDrone.Core.Test.ProviderTests
//Assert
result . Should ( ) . NotBeNull ( ) ;
result . Quality . Should ( ) . Be ( QualityTypes . Bluray72 0p) ;
result . Proper . Should ( ) . Be Tru e( ) ;
result . Quality . Should ( ) . Be ( QualityTypes . WEBDL108 0p) ;
result . Proper . Should ( ) . Be Fals e( ) ;
}
[Test]