EpisodesWithoutFiles now skips ignored episodes, Tests updated.

pull/2/head
Mark McDowall 13 years ago
parent 4f68d07c9a
commit 412a3fc476

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

@ -162,7 +162,7 @@ namespace NzbDrone.Core.Providers
var episodes = _database.Query<Episode, Series>(@"SELECT Episodes.*, Series.Title FROM Episodes var episodes = _database.Query<Episode, Series>(@"SELECT Episodes.*, Series.Title FROM Episodes
INNER JOIN Series INNER JOIN Series
ON Episodes.SeriesId = Series.SeriesId 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); DateTime.Now.Date);
if (!includeSpecials) if (!includeSpecials)
return episodes.Where(e => e.SeasonNumber > 0).ToList(); return episodes.Where(e => e.SeasonNumber > 0).ToList();

Loading…
Cancel
Save