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