2011-10-21 01:42:17 +02:00
|
|
|
|
using System.Collections.Generic;
|
2011-08-28 21:07:56 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2012-01-24 07:29:32 +01:00
|
|
|
|
using FluentAssertions;
|
2011-08-28 21:07:56 +02:00
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2013-02-24 07:48:52 +01:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2013-03-05 06:51:07 +01:00
|
|
|
|
using NzbDrone.Core.Jobs.Implementations;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2012-01-24 07:29:32 +01:00
|
|
|
|
using NzbDrone.Core.Model;
|
2011-08-28 21:07:56 +02:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-03-07 02:51:47 +01:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2012-09-11 08:35:25 +02:00
|
|
|
|
using NzbDrone.Test.Common;
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2011-10-21 01:42:17 +02:00
|
|
|
|
namespace NzbDrone.Core.Test.JobTests
|
2011-08-28 21:07:56 +02:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-02-19 02:57:08 +01:00
|
|
|
|
public class BacklogSearchJobTest : CoreTest<BacklogSearchJob>
|
2011-08-28 21:07:56 +02:00
|
|
|
|
{
|
2012-01-15 03:05:05 +01:00
|
|
|
|
private void WithEnableBacklogSearching()
|
|
|
|
|
{
|
2013-02-24 20:39:31 +01:00
|
|
|
|
Mocker.GetMock<IConfigService>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
|
2012-01-15 03:05:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
[Test]
|
2011-10-09 04:16:11 +02:00
|
|
|
|
public void no_missing_epsiodes_should_not_trigger_any_search()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var notification = new ProgressNotification("Backlog Search Job Test");
|
|
|
|
|
|
|
|
|
|
var episodes = new List<Episode>();
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
WithStrictMocker();
|
2012-01-15 03:05:05 +01:00
|
|
|
|
WithEnableBacklogSearching();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Subject.Start(notification, null);
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-09-10 21:04:17 +02:00
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
2011-08-28 21:07:56 +02:00
|
|
|
|
Times.Never());
|
|
|
|
|
|
2012-09-10 21:04:17 +02:00
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = 0 }),
|
2011-08-28 21:07:56 +02:00
|
|
|
|
Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-10-09 04:16:11 +02:00
|
|
|
|
public void individual_missing_episode()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var notification = new ProgressNotification("Backlog Search Job Test");
|
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.Series = series)
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2012-01-15 03:05:05 +01:00
|
|
|
|
WithEnableBacklogSearching();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>()
|
2012-09-11 08:35:25 +02:00
|
|
|
|
.Setup(s => s.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") == 1)));
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Subject.Start(notification, null);
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-09-11 08:35:25 +02:00
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
2011-08-28 21:07:56 +02:00
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void individual_missing_episodes_only()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var notification = new ProgressNotification("Backlog Search Job Test");
|
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.Series = series)
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2012-01-15 03:05:05 +01:00
|
|
|
|
WithEnableBacklogSearching();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Subject.Start(notification, null);
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-09-11 08:35:25 +02:00
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
2011-08-28 21:07:56 +02:00
|
|
|
|
Times.Exactly(episodes.Count));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void series_season_missing_episodes_only_mismatch_count()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var notification = new ProgressNotification("Backlog Search Job Test");
|
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(5)
|
2011-10-18 23:46:06 +02:00
|
|
|
|
.All()
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.With(e => e.Series = series)
|
2011-10-18 23:46:06 +02:00
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2012-01-15 03:05:05 +01:00
|
|
|
|
WithEnableBacklogSearching();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-10-20 07:05:04 +02:00
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Subject.Start(notification, null);
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-09-11 08:35:25 +02:00
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
|
|
|
|
Times.Exactly(episodes.Count));
|
2011-08-28 21:07:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void series_season_missing_episodes_only()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var notification = new ProgressNotification("Backlog Search Job Test");
|
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(5)
|
2011-10-18 23:46:06 +02:00
|
|
|
|
.All()
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.With(e => e.Series = series)
|
2013-02-26 04:58:57 +01:00
|
|
|
|
.With(e => e.SeriesId = series.Id)
|
2011-10-18 23:46:06 +02:00
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2012-01-15 03:05:05 +01:00
|
|
|
|
WithEnableBacklogSearching();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Subject.Start(notification, null);
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
2012-09-11 08:35:25 +02:00
|
|
|
|
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
2011-08-28 21:07:56 +02:00
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void multiple_missing_episodes()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var notification = new ProgressNotification("Backlog Search Job Test");
|
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series2 = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-08-28 21:07:56 +02:00
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(10)
|
2011-10-18 23:46:06 +02:00
|
|
|
|
.TheFirst(5)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.With(e => e.Series = series)
|
2013-02-26 04:58:57 +01:00
|
|
|
|
.With(e => e.SeriesId = series.Id)
|
2011-10-18 23:46:06 +02:00
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.TheNext(5)
|
|
|
|
|
.With(e => e.Series = series2)
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2012-01-15 03:05:05 +01:00
|
|
|
|
WithEnableBacklogSearching();
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-08-28 21:07:56 +02:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2011-10-20 07:05:04 +02:00
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
Subject.Start(notification, null);
|
2011-08-28 21:07:56 +02:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-09-11 08:35:25 +02:00
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
|
|
|
|
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
2011-08-28 21:07:56 +02:00
|
|
|
|
Times.Once());
|
|
|
|
|
|
2012-09-11 08:35:25 +02:00
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
|
|
|
|
Times.Exactly(5));
|
2011-08-28 21:07:56 +02:00
|
|
|
|
}
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored_series()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateListOfSize(2)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(s => s.Monitored = false)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.TheNext(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(11)
|
|
|
|
|
.TheFirst(5)
|
|
|
|
|
.With(e => e.Series = series[0])
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.TheLast(6)
|
|
|
|
|
.With(e => e.Series = series[1])
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
var result = Subject.GetMissingForEnabledSeries();
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
|
result.Should().Contain(s => s.Series.Monitored);
|
|
|
|
|
result.Should().NotContain(s => !s.Series.Monitored);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_series_when_backlog_searching_is_ignored()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateListOfSize(3)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Disable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.TheNext(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.TheNext(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Inherit)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(12)
|
|
|
|
|
.TheFirst(3)
|
|
|
|
|
.With(e => e.Series = series[0])
|
|
|
|
|
.TheNext(4)
|
|
|
|
|
.With(e => e.Series = series[1])
|
|
|
|
|
.TheNext(5)
|
|
|
|
|
.With(e => e.Series = series[2])
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
|
|
|
|
//WithEnableBacklogSearching();
|
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
var result = Subject.GetMissingForEnabledSeries();
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
result.Should().NotBeEmpty();
|
2012-01-26 02:02:21 +01:00
|
|
|
|
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
|
|
|
|
|
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
|
|
|
|
|
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Inherit);
|
2012-01-24 07:29:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inherit_series_when_backlog_searching_is_enabled()
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
var series = Builder<Series>.CreateListOfSize(3)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Disable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.TheNext(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.TheNext(1)
|
|
|
|
|
.With(s => s.Monitored = true)
|
2012-01-26 02:02:21 +01:00
|
|
|
|
.With(s => s.BacklogSetting = BacklogSettingType.Inherit)
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(12)
|
|
|
|
|
.TheFirst(3)
|
|
|
|
|
.With(e => e.Series = series[0])
|
|
|
|
|
.TheNext(4)
|
|
|
|
|
.With(e => e.Series = series[1])
|
|
|
|
|
.TheNext(5)
|
|
|
|
|
.With(e => e.Series = series[2])
|
2013-03-04 00:18:43 +01:00
|
|
|
|
.Build().ToList();
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
2013-02-22 01:47:09 +01:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2012-01-24 07:29:32 +01:00
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 02:57:08 +01:00
|
|
|
|
var result = Subject.GetMissingForEnabledSeries();
|
2012-01-24 07:29:32 +01:00
|
|
|
|
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-01-24 07:29:32 +01:00
|
|
|
|
result.Should().NotBeEmpty();
|
2012-01-26 02:02:21 +01:00
|
|
|
|
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
|
|
|
|
|
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
|
|
|
|
|
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Inherit);
|
2012-01-24 07:29:32 +01:00
|
|
|
|
}
|
2011-08-28 21:07:56 +02:00
|
|
|
|
}
|
|
|
|
|
}
|