diff --git a/NzbDrone.Core.Test/UpcomingEpisodesProviderTest.cs b/NzbDrone.Core.Test/UpcomingEpisodesProviderTest.cs index 8a6b3f8f0..cbe7dc291 100644 --- a/NzbDrone.Core.Test/UpcomingEpisodesProviderTest.cs +++ b/NzbDrone.Core.Test/UpcomingEpisodesProviderTest.cs @@ -25,6 +25,7 @@ public class UpcomingEpisodesProviderTest : TestBase episodes = Builder.CreateListOfSize(6) .WhereAll() .Have(e => e.SeriesId = 1) + .Have(e => e.Ignored = false) .WhereTheFirst(1) .Has(e => e.AirDate = DateTime.Today.AddDays(-1)) .AndTheNext(1) @@ -128,5 +129,87 @@ public void Get_Week() result.Last().Series.Should().NotBeNull(); result.Last().Series.SeriesId.Should().NotBe(0); } + + [Test] + public void Get_Yesterday_skip_ingored() + { + //Setup + var database = MockLib.GetEmptyDatabase(); + var mocker = new AutoMoqer(); + mocker.SetConstant(database); + + episodes.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).Single().Ignored = true; + + database.InsertMany(episodes); + database.Insert(series); + + //Act + var result = mocker.Resolve().Yesterday(); + + //Assert + result.Should().BeEmpty(); + } + + [Test] + public void Get_Today_skip_ingored() + { + //Setup + var database = MockLib.GetEmptyDatabase(); + var mocker = new AutoMoqer(); + mocker.SetConstant(database); + + episodes.Where(e => e.AirDate == DateTime.Today).Single().Ignored = true; + + database.InsertMany(episodes); + database.Insert(series); + + //Act + var result = mocker.Resolve().Today(); + + //Assert + result.Should().BeEmpty(); + } + + [Test] + public void Get_Tomorrow_skip_ingored() + { + //Setup + var database = MockLib.GetEmptyDatabase(); + var mocker = new AutoMoqer(); + mocker.SetConstant(database); + + episodes.Where(e => e.AirDate == DateTime.Today.AddDays(1)).Single().Ignored = true; + + database.InsertMany(episodes); + database.Insert(series); + + //Act + var result = mocker.Resolve().Tomorrow(); + + //Assert + result.Should().BeEmpty(); + } + + [Test] + public void Get_Week_skip_ingored() + { + //Setup + var database = MockLib.GetEmptyDatabase(); + var mocker = new AutoMoqer(); + mocker.SetConstant(database); + + episodes.Where(e => e.AirDate == DateTime.Today.AddDays(2)).Single().Ignored = true; + + database.InsertMany(episodes); + database.Insert(series); + + //Act + var result = mocker.Resolve().Week(); + + //Assert + result.Should().HaveCount(1); + result.First().Series.Should().NotBeNull(); + result.First().Series.SeriesId.Should().NotBe(0); + } } } diff --git a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs index 423f33947..2f4e5651e 100644 --- a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs +++ b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs @@ -22,7 +22,7 @@ public virtual UpcomingEpisodesModel Upcoming() { var allEps = _database.Fetch(@"SELECT * FROM Episodes INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId - WHERE AirDate BETWEEN @0 AND @1", + WHERE Ignored = 0 AND AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(-1), DateTime.Today.AddDays(8)); var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); @@ -36,28 +36,28 @@ public virtual List Yesterday() { return _database.Fetch(@"SELECT * FROM Episodes INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId - WHERE AirDate = @0", DateTime.Today.AddDays(-1)); + WHERE Ignored = 0 AND AirDate = @0", DateTime.Today.AddDays(-1)); } public virtual List Today() { return _database.Fetch(@"SELECT * FROM Episodes INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId - WHERE AirDate = @0", DateTime.Today); + WHERE Ignored = 0 AND AirDate = @0", DateTime.Today); } public virtual List Tomorrow() { return _database.Fetch(@"SELECT * FROM Episodes INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId - WHERE AirDate = @0", DateTime.Today.AddDays(1)); + WHERE Ignored = 0 AND AirDate = @0", DateTime.Today.AddDays(1)); } public virtual List Week() { return _database.Fetch(@"SELECT * FROM Episodes INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId - WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8)); + WHERE Ignored = 0 AND AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8)); } } } \ No newline at end of file