From 57690f49a0646eea84630ceab83eafe869c7f55c Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 4 Jun 2011 23:24:24 -0700 Subject: [PATCH] Fixed IsSeasonIgnore logic, added tests --- NzbDrone.Core.Test/EpisodeProviderTest.cs | 88 +++++++++++++++++++++ NzbDrone.Core/Providers/EpisodeProvider.cs | Bin 10740 -> 10742 bytes 2 files changed, 88 insertions(+) diff --git a/NzbDrone.Core.Test/EpisodeProviderTest.cs b/NzbDrone.Core.Test/EpisodeProviderTest.cs index 35dfd4f0e..a1a09a6b5 100644 --- a/NzbDrone.Core.Test/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/EpisodeProviderTest.cs @@ -256,6 +256,92 @@ namespace NzbDrone.Core.Test } + [Test] + public void IsSeasonIgnored_should_return_true_if_all_episodes_ignored() + { + var repo = MockLib.GetEmptyRepository(); + var mocker = new AutoMoqer(MockBehavior.Strict); + mocker.SetConstant(repo); + + var episodes = Builder.CreateListOfSize(4) + .WhereAll() + .Have(c => c.Ignored = true) + .Have(c => c.SeriesId = 10) + .Have(c => c.SeasonNumber = 2) + .Build(); + + repo.AddMany(episodes); + + //Act + var result = mocker.Resolve().IsIgnored(10, 2); + + //Assert + result.Should().BeTrue(); + } + + [Test] + public void IsSeasonIgnored_should_return_false_if_none_of_episodes_are_ignored() + { + var repo = MockLib.GetEmptyRepository(); + var mocker = new AutoMoqer(MockBehavior.Strict); + mocker.SetConstant(repo); + + var episodes = Builder.CreateListOfSize(4) + .WhereAll() + .Have(c => c.Ignored = false) + .Have(c => c.SeriesId = 10) + .Have(c => c.SeasonNumber = 2) + .Build(); + + repo.AddMany(episodes); + + //Act + var result = mocker.Resolve().IsIgnored(10, 2); + + //Assert + result.Should().BeFalse(); + } + + [Test] + public void IsSeasonIgnored_should_return_false_if_some_of_episodes_are_ignored() + { + var repo = MockLib.GetEmptyRepository(); + var mocker = new AutoMoqer(MockBehavior.Strict); + mocker.SetConstant(repo); + + var episodes = Builder.CreateListOfSize(4) + .WhereAll() + .Have(c => c.SeriesId = 10) + .Have(c => c.SeasonNumber = 2) + .Have(c => c.Ignored = true) + .Build(); + + episodes[2].Ignored = false; + + + repo.AddMany(episodes); + + //Act + var result = mocker.Resolve().IsIgnored(10, 2); + + //Assert + result.Should().BeFalse(); + } + + [Test] + public void IsSeasonIgnored_should_return_true_if_invalid_series() + { + var repo = MockLib.GetEmptyRepository(); + var mocker = new AutoMoqer(MockBehavior.Strict); + mocker.SetConstant(repo); + + //Act + var result = mocker.Resolve().IsIgnored(10, 2); + + //Assert + result.Should().BeTrue(); + } + [Test] [Explicit] public void Add_daily_show_episodes() @@ -276,5 +362,7 @@ namespace NzbDrone.Core.Test var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId); episodes.Should().NotBeEmpty(); } + + } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index e6135751c182ac01edc8f51153a99fb52d2042b4..05ce49b69b94be8357d0a2fd701dc511840b1c2d 100644 GIT binary patch delta 26 icmewo{4IDxrZ}VG2>}3zZV0Xb delta 20 ccmews{3UoprugIq%si9J!~-{<5Z4m|0A$SwMgRZ+