diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 26967ac0a..16f498630 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -181,6 +181,8 @@
+
+
diff --git a/NzbDrone.Core.Test/TvTests/SeasonServiceTests/SetMonitoredFixture.cs b/NzbDrone.Core.Test/TvTests/SeasonServiceTests/SetMonitoredFixture.cs
new file mode 100644
index 000000000..775d7d41c
--- /dev/null
+++ b/NzbDrone.Core.Test/TvTests/SeasonServiceTests/SetMonitoredFixture.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
+
+namespace NzbDrone.Core.Test.TvTests.SeasonServiceTests
+{
+ [TestFixture]
+ public class SetMonitoredFixture : CoreTest
+ {
+ private Season _season;
+
+ [SetUp]
+ public void Setup()
+ {
+ _season = new Season
+ {
+ Id = 1,
+ SeasonNumber = 1,
+ SeriesId = 1,
+ Monitored = false
+ };
+
+ Mocker.GetMock()
+ .Setup(s => s.Get(It.IsAny(), It.IsAny()))
+ .Returns(_season);
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void should_update_season(bool monitored)
+ {
+ Subject.SetMonitored(_season.SeriesId, _season.SeasonNumber, monitored);
+
+ Mocker.GetMock()
+ .Verify(v => v.Update(_season), Times.Once());
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void should_update_episodes_in_season(bool monitored)
+ {
+ Subject.SetMonitored(_season.SeriesId, _season.SeasonNumber, monitored);
+
+ Mocker.GetMock()
+ .Verify(v => v.SetEpisodeMonitoredBySeason(_season.SeriesId, _season.SeasonNumber, monitored), Times.Once());
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/TvTests/SeasonServiceTests/SetSeasonPassFixture.cs b/NzbDrone.Core.Test/TvTests/SeasonServiceTests/SetSeasonPassFixture.cs
new file mode 100644
index 000000000..b8ac4a9ea
--- /dev/null
+++ b/NzbDrone.Core.Test/TvTests/SeasonServiceTests/SetSeasonPassFixture.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
+
+namespace NzbDrone.Core.Test.TvTests.SeasonServiceTests
+{
+ [TestFixture]
+ public class SetSeasonPassFixture : CoreTest
+ {
+ private const Int32 SERIES_ID = 1;
+ private List _seasons;
+
+ [SetUp]
+ public void Setup()
+ {
+ _seasons = Builder.CreateListOfSize(5)
+ .All()
+ .With(s => s.SeriesId = SERIES_ID)
+ .Build()
+ .ToList();
+
+ Mocker.GetMock()
+ .Setup(s => s.GetSeasonBySeries(It.IsAny()))
+ .Returns(_seasons);
+ }
+
+ [Test]
+ public void should_updateMany()
+ {
+ Subject.SetSeasonPass(SERIES_ID, 1);
+
+ Mocker.GetMock()
+ .Verify(v => v.UpdateMany(It.IsAny>()), Times.Once());
+ }
+
+ [Test]
+ public void should_set_lower_seasons_to_false()
+ {
+ const int seasonNumber = 3;
+
+ var result = Subject.SetSeasonPass(SERIES_ID, seasonNumber);
+
+ result.Where(s => s.SeasonNumber < seasonNumber).Should().OnlyContain(s => s.Monitored == false);
+ }
+
+ [Test]
+ public void should_set_equal_or_higher_seasons_to_false()
+ {
+ const int seasonNumber = 3;
+
+ var result = Subject.SetSeasonPass(SERIES_ID, seasonNumber);
+
+ result.Where(s => s.SeasonNumber >= seasonNumber).Should().OnlyContain(s => s.Monitored == true);
+ }
+
+ [Test]
+ public void should_set_episodes_in_lower_seasons_to_false()
+ {
+ const int seasonNumber = 3;
+
+ Subject.SetSeasonPass(SERIES_ID, seasonNumber);
+
+ Mocker.GetMock()
+ .Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is(i => i < seasonNumber), false), Times.AtLeastOnce());
+
+ Mocker.GetMock()
+ .Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is(i => i < seasonNumber), true), Times.Never());
+ }
+
+ [Test]
+ public void should_set_episodes_in_equal_or_higher_seasons_to_false()
+ {
+ const int seasonNumber = 3;
+
+ Subject.SetSeasonPass(SERIES_ID, seasonNumber);
+
+ Mocker.GetMock()
+ .Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is(i => i >= seasonNumber), true), Times.AtLeastOnce());
+
+ Mocker.GetMock()
+ .Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is(i => i >= seasonNumber), false), Times.Never());
+ }
+ }
+}
diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs
index 1231d1384..dce584fa4 100644
--- a/NzbDrone.Core/Tv/EpisodeService.cs
+++ b/NzbDrone.Core/Tv/EpisodeService.cs
@@ -31,6 +31,7 @@ namespace NzbDrone.Core.Tv
void InsertMany(List episodes);
void UpdateMany(List episodes);
void DeleteMany(List episodes);
+ void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored);
}
public class EpisodeService : IEpisodeService,
diff --git a/NzbDrone.Core/Tv/SeasonService.cs b/NzbDrone.Core/Tv/SeasonService.cs
index 988281a55..de0c4013d 100644
Binary files a/NzbDrone.Core/Tv/SeasonService.cs and b/NzbDrone.Core/Tv/SeasonService.cs differ