1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-25 17:17:02 +00:00

EpisodesWithoutFiles now skips ignored episodes, Tests updated.

This commit is contained in:
Mark McDowall 2011-08-03 22:56:42 -07:00
parent 4f68d07c9a
commit 412a3fc476
2 changed files with 19 additions and 5 deletions

View file

@ -1151,8 +1151,11 @@ public void EpisodesWithoutFiles_no_specials()
.Have(c => c.SeriesId = 10)
.Have(c => c.SeasonNumber = 1)
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
.Have(c => c.Ignored = true)
.WhereTheFirst(2)
.Have(c => c.EpisodeFileId = 0)
.WhereSection(1, 2)
.Have(c => c.Ignored = false)
.Build().ToList();
var specials = Builder<Episode>.CreateListOfSize(2)
@ -1161,6 +1164,10 @@ public void EpisodesWithoutFiles_no_specials()
.Have(c => c.SeasonNumber = 0)
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
.Have(c => c.EpisodeFileId = 0)
.WhereTheFirst(1)
.Have(c => c.Ignored = true)
.AndTheRemaining()
.Have(c => c.Ignored = false)
.Build().ToList();
db.Insert(series);
@ -1171,8 +1178,8 @@ public void EpisodesWithoutFiles_no_specials()
var missingFiles= mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(false);
//Assert
missingFiles.Should().HaveCount(2);
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(2);
missingFiles.Should().HaveCount(1);
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(1);
mocker.VerifyAllMocks();
}
@ -1193,8 +1200,11 @@ public void EpisodesWithoutFiles_with_specials()
.Have(c => c.SeriesId = 10)
.Have(c => c.SeasonNumber = 1)
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
.Have(c => c.Ignored = true)
.WhereTheFirst(2)
.Have(c => c.EpisodeFileId = 0)
.WhereSection(1,2)
.Have(c => c.Ignored = false)
.Build().ToList();
var specials = Builder<Episode>.CreateListOfSize(2)
@ -1203,6 +1213,10 @@ public void EpisodesWithoutFiles_with_specials()
.Have(c => c.SeasonNumber = 0)
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
.Have(c => c.EpisodeFileId = 0)
.WhereTheFirst(1)
.Have(c => c.Ignored = true)
.AndTheRemaining()
.Have(c => c.Ignored = false)
.Build().ToList();
db.Insert(series);
@ -1213,8 +1227,8 @@ public void EpisodesWithoutFiles_with_specials()
var missingFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(true);
//Assert
missingFiles.Should().HaveCount(4);
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(4);
missingFiles.Should().HaveCount(2);
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(2);
mocker.VerifyAllMocks();
}

View file

@ -162,7 +162,7 @@ public virtual IList<Episode> EpisodesWithoutFiles(bool includeSpecials)
var episodes = _database.Query<Episode, Series>(@"SELECT Episodes.*, Series.Title FROM Episodes
INNER JOIN Series
ON Episodes.SeriesId = Series.SeriesId
WHERE (EpisodeFileId=0 OR EpisodeFileId=NULL) AND AirDate<=@0",
WHERE (EpisodeFileId=0 OR EpisodeFileId=NULL) AND Ignored = 0 AND AirDate<=@0",
DateTime.Now.Date);
if (!includeSpecials)
return episodes.Where(e => e.SeasonNumber > 0).ToList();