@ -439,7 +439,6 @@ namespace NzbDrone.Core.Test.ProviderTests
result . Should ( ) . HaveSameCount ( fakeEpisodes . Episodes ) ;
}
[Test]
public void RefreshEpisodeInfo_ignore_season_zero ( )
{
@ -466,6 +465,10 @@ namespace NzbDrone.Core.Test.ProviderTests
. Setup ( c = > c . GetSeries ( seriesId , true ) )
. Returns ( fakeEpisodes ) ;
Mocker . GetMock < SeasonProvider > ( )
. Setup ( s = > s . IsIgnored ( seriesId , 0 ) )
. Returns ( true ) ;
//Act
Mocker . Resolve < EpisodeProvider > ( ) . RefreshEpisodeInfo ( fakeSeries ) ;
@ -694,6 +697,10 @@ namespace NzbDrone.Core.Test.ProviderTests
. Setup ( c = > c . GetSeries ( seriesId , true ) )
. Returns ( tvdbSeries ) ;
Mocker . GetMock < SeasonProvider > ( )
. Setup ( s = > s . IsIgnored ( seriesId , It . IsAny < int > ( ) ) )
. Returns ( true ) ;
//Act
Mocker . Resolve < EpisodeProvider > ( ) . RefreshEpisodeInfo ( fakeSeries ) ;
@ -704,180 +711,6 @@ namespace NzbDrone.Core.Test.ProviderTests
result . Where ( e = > e . Ignored ) . Should ( ) . HaveCount ( episodeCount ) ;
}
[Test]
public void IsSeasonIgnored_should_return_true_if_all_episodes_ignored ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . Ignored = true )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 2 )
. Build ( ) ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 2 ) ;
//Assert
result . Should ( ) . BeTrue ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_false_if_none_of_episodes_are_ignored ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . Ignored = false )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 2 )
. Build ( ) ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 2 ) ;
//Assert
result . Should ( ) . BeFalse ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_false_if_some_of_episodes_are_ignored ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 2 )
. With ( c = > c . Ignored = true )
. Build ( ) ;
episodes [ 2 ] . Ignored = false ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 2 ) ;
//Assert
result . Should ( ) . BeFalse ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_false_if_zero_episodes_in_db_for_season ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 3 )
. With ( c = > c . Ignored = true )
. Build ( ) ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 2 ) ;
//Assert
result . Should ( ) . BeFalse ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_true_if_zero_episodes_in_db_for_season_and_previous_is_ignored ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 3 )
. With ( c = > c . Ignored = true )
. Build ( ) ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 4 ) ;
//Assert
result . Should ( ) . BeTrue ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_false_if_zero_episodes_in_db_for_season_and_previous_is_not_ignored ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 3 )
. With ( c = > c . Ignored = false )
. Build ( ) ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 4 ) ;
//Assert
result . Should ( ) . BeFalse ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_false_if_zero_episodes_in_db_for_season_one ( )
{
WithRealDb ( ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 1 ) ;
//Assert
result . Should ( ) . BeFalse ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_true_if_zero_episodes_in_db_for_season_zero ( )
{
WithRealDb ( ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 0 ) ;
//Assert
result . Should ( ) . BeTrue ( ) ;
}
[Test]
public void IsSeasonIgnored_should_return_false_if_season_zero_is_not_ignored ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 0 )
. With ( c = > c . Ignored = false )
. Build ( ) ;
episodes . ToList ( ) . ForEach ( c = > Db . Insert ( c ) ) ;
//Act
var result = Mocker . Resolve < EpisodeProvider > ( ) . IsIgnored ( 10 , 0 ) ;
//Assert
result . Should ( ) . BeFalse ( ) ;
}
[Test]
[Explicit]
public void Add_daily_show_episodes ( )
@ -1049,6 +882,10 @@ namespace NzbDrone.Core.Test.ProviderTests
. With ( e = > e . Ignored = false )
. Build ( ) ;
Mocker . GetMock < SeasonProvider > ( )
. Setup ( s = > s . IsIgnored ( newEpisode . SeriesId , newEpisode . SeasonNumber ) )
. Returns ( true ) ;
//Act
Mocker . Resolve < EpisodeProvider > ( ) . AddEpisode ( newEpisode ) ;
@ -1263,6 +1100,42 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker . VerifyAllMocks ( ) ;
}
[Test]
public void IgnoreSeason_should_call_SetIgnore_in_season_provider_one_time_only ( )
{
WithRealDb ( ) ;
var episodes = Builder < Episode > . CreateListOfSize ( 4 )
. All ( )
. With ( c = > c . SeriesId = 10 )
. With ( c = > c . SeasonNumber = 1 )
. With ( c = > c . Ignored = false )
. Build ( ) . ToList ( ) ;
var season = new Season
{
SeriesId = 10 ,
SeasonNumber = 1 ,
Ignored = false
} ;
Db . Insert ( season ) ;
Db . InsertMany ( episodes ) ;
Mocker . GetMock < SeasonProvider > ( ) . Setup ( s = > s . SetIgnore ( 10 , 1 , true ) ) . Verifiable ( ) ;
//Act
Mocker . Resolve < EpisodeProvider > ( ) . SetSeasonIgnore ( 10 , 1 , true ) ;
//Assert
var episodesInDb = Db . Fetch < Episode > ( @"SELECT * FROM Episodes" ) ;
episodesInDb . Should ( ) . HaveCount ( 4 ) ;
episodesInDb . Where ( e = > e . Ignored ) . Should ( ) . HaveCount ( 4 ) ;
Mocker . GetMock < SeasonProvider > ( ) . Verify ( s = > s . SetIgnore ( 10 , 1 , true ) , Times . Once ( ) ) ;
}
[Test]
public void EpisodesWithoutFiles_no_specials ( )
{