From 412a3fc476d4690a138bba244ce867d76acc143c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 3 Aug 2011 22:56:42 -0700 Subject: [PATCH] EpisodesWithoutFiles now skips ignored episodes, Tests updated. --- NzbDrone.Core.Test/EpisodeProviderTest.cs | 22 ++++++++++++++++++---- NzbDrone.Core/Providers/EpisodeProvider.cs | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/NzbDrone.Core.Test/EpisodeProviderTest.cs b/NzbDrone.Core.Test/EpisodeProviderTest.cs index 029f134e6..a4f078c5f 100644 --- a/NzbDrone.Core.Test/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/EpisodeProviderTest.cs @@ -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.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().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.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().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(); } diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index 40c0475c2..d0cf2858b 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -162,7 +162,7 @@ public virtual IList EpisodesWithoutFiles(bool includeSpecials) var episodes = _database.Query(@"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();