mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
SeasonPass now properly updates episodes
This commit is contained in:
parent
9fcd91f2c5
commit
55af8ecb18
@ -181,6 +181,8 @@
|
||||
<Compile Include="ProviderTests\DiskProviderTests\ArchiveProviderFixture.cs" />
|
||||
<Compile Include="MediaFileTests\DropFolderImportServiceFixture.cs" />
|
||||
<Compile Include="SeriesStatsTests\SeriesStatisticsFixture.cs" />
|
||||
<Compile Include="TvTests\SeasonServiceTests\SetSeasonPassFixture.cs" />
|
||||
<Compile Include="TvTests\SeasonServiceTests\SetMonitoredFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesRepositoryTests\QualityProfileRepositoryFixture.cs" />
|
||||
<Compile Include="UpdateTests\UpdateServiceFixture.cs" />
|
||||
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetSceneTvdbMappingsFixture.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<SeasonService>
|
||||
{
|
||||
private Season _season;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_season = new Season
|
||||
{
|
||||
Id = 1,
|
||||
SeasonNumber = 1,
|
||||
SeriesId = 1,
|
||||
Monitored = false
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<Int32>(), It.IsAny<Int32>()))
|
||||
.Returns(_season);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void should_update_season(bool monitored)
|
||||
{
|
||||
Subject.SetMonitored(_season.SeriesId, _season.SeasonNumber, monitored);
|
||||
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.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<IEpisodeService>()
|
||||
.Verify(v => v.SetEpisodeMonitoredBySeason(_season.SeriesId, _season.SeasonNumber, monitored), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<SeasonService>
|
||||
{
|
||||
private const Int32 SERIES_ID = 1;
|
||||
private List<Season> _seasons;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_seasons = Builder<Season>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.SeriesId = SERIES_ID)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(s => s.GetSeasonBySeries(It.IsAny<Int32>()))
|
||||
.Returns(_seasons);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_updateMany()
|
||||
{
|
||||
Subject.SetSeasonPass(SERIES_ID, 1);
|
||||
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Verify(v => v.UpdateMany(It.IsAny<List<Season>>()), 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<IEpisodeService>()
|
||||
.Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is<Int32>(i => i < seasonNumber), false), Times.AtLeastOnce());
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is<Int32>(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<IEpisodeService>()
|
||||
.Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is<Int32>(i => i >= seasonNumber), true), Times.AtLeastOnce());
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.SetEpisodeMonitoredBySeason(SERIES_ID, It.Is<Int32>(i => i >= seasonNumber), false), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ public interface IEpisodeService
|
||||
void InsertMany(List<Episode> episodes);
|
||||
void UpdateMany(List<Episode> episodes);
|
||||
void DeleteMany(List<Episode> episodes);
|
||||
void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored);
|
||||
}
|
||||
|
||||
public class EpisodeService : IEpisodeService,
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user