parent
81ac359f71
commit
c21cacd309
|
@ -223,6 +223,41 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
|
|||
.Verify(v => v.UpdateEpisodes(It.Is<List<Episode>>(l => l.All(e => !e.Monitored))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_monitor_latest_season_if_some_episodes_have_aired()
|
||||
{
|
||||
_series.Seasons = Builder<Season>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(n => n.Monitored = true)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
_episodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-100))
|
||||
.TheLast(2)
|
||||
.With(e => e.SeasonNumber = 2)
|
||||
.TheLast(1)
|
||||
.With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(100))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
var monitoringOptions = new MonitoringOptions
|
||||
{
|
||||
Monitor = MonitorTypes.LatestSeason
|
||||
};
|
||||
|
||||
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
|
||||
|
||||
VerifySeasonMonitored(n => n.SeasonNumber == 2);
|
||||
VerifyMonitored(n => n.SeasonNumber == 2);
|
||||
|
||||
VerifySeasonNotMonitored(n => n.SeasonNumber == 1);
|
||||
VerifyNotMonitored(n => n.SeasonNumber == 1);
|
||||
}
|
||||
|
||||
private void VerifyMonitored(Func<Episode, bool> predicate)
|
||||
{
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
|
|
|
@ -79,7 +79,9 @@ namespace NzbDrone.Core.Tv
|
|||
case MonitorTypes.LatestSeason:
|
||||
|
||||
if (episodes.Where(e => e.SeasonNumber == lastSeason)
|
||||
.All(e => e.AirDateUtc.HasValue && !e.AirDateUtc.Value.InLastDays(90)))
|
||||
.All(e => e.AirDateUtc.HasValue &&
|
||||
e.AirDateUtc.Value.Before(DateTime.UtcNow) &&
|
||||
!e.AirDateUtc.Value.InLastDays(90)))
|
||||
{
|
||||
_logger.Debug("[{0}] Unmonitoring all episodes because latest season aired more than 90 days ago", series.Title);
|
||||
ToggleEpisodesMonitoredState(episodes, e => false);
|
||||
|
|
Loading…
Reference in New Issue