From ceec4200356f88427f24347c339fb24960fa6eda Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 2 Dec 2011 00:35:56 -0800 Subject: [PATCH] Added test to verify EpisodeInfo would ignore new episodes for an ignored season (no bug here). --- .../ProviderTests/EpisodeProviderTest.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs index 6d1f46385..86e2a637b 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs @@ -582,6 +582,57 @@ namespace NzbDrone.Core.Test.ProviderTests updatedEpisodes.Should().OnlyContain(c => c.Ignored == true); } + [Test] + public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season() + { + //Arrange + const int seriesId = 71663; + const int episodeCount = 2; + + var fakeEpisode = Builder.CreateNew() + .With(e => e.SeasonNumber = 5) + .With(e => e.EpisodeNumber = 1) + .With(e => e.TvDbEpisodeId = 11) + .With(e => e.SeriesId = seriesId) + .With(e => e.Ignored = true) + .Build(); + + var tvdbSeries = Builder.CreateNew().With( + c => c.Episodes = + new List(Builder.CreateListOfSize(episodeCount). + All() + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) + .With(e => e.SeasonNumber = 5) + .TheFirst(1) + .With(e => e.EpisodeNumber = 1) + .With(e => e.Id = 11) + .TheNext(1) + .With(e => e.EpisodeNumber = 2) + .With(e => e.Id = 22) + .Build()) + ).With(c => c.Id = seriesId).Build(); + + var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build(); + + WithRealDb(); + + Db.Insert(fakeSeries); + Db.Insert(fakeEpisode); + + Mocker.GetMock() + .Setup(c => c.GetSeries(seriesId, true)) + .Returns(tvdbSeries); + + //Act + Mocker.Resolve().RefreshEpisodeInfo(fakeSeries); + + //Assert + var result = Mocker.Resolve().GetEpisodeBySeries(seriesId).ToList(); + Mocker.GetMock().VerifyAll(); + result.Should().HaveCount(episodeCount); + result.Where(e => e.Ignored).Should().HaveCount(episodeCount); + } + [Test] public void IsSeasonIgnored_should_return_true_if_all_episodes_ignored() {