2013-04-15 03:33:03 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-08-07 03:18:05 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
2013-08-08 03:30:20 +00:00
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
2013-04-15 01:41:39 +00:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 02:19:38 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-04-15 01:41:39 +00:00
|
|
|
|
|
|
|
|
|
public class MonitoredEpisodeSpecificationFixture : CoreTest<MonitoredEpisodeSpecification>
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-04-15 03:33:03 +00:00
|
|
|
|
private MonitoredEpisodeSpecification _monitoredEpisodeSpecification;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
|
2013-04-15 03:33:03 +00:00
|
|
|
|
private RemoteEpisode _parseResultMulti;
|
|
|
|
|
private RemoteEpisode _parseResultSingle;
|
|
|
|
|
private Series _fakeSeries;
|
|
|
|
|
private Episode _firstEpisode;
|
|
|
|
|
private Episode _secondEpisode;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-04-15 03:33:03 +00:00
|
|
|
|
_monitoredEpisodeSpecification = Mocker.Resolve<MonitoredEpisodeSpecification>();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
|
2013-04-15 03:33:03 +00:00
|
|
|
|
_fakeSeries = Builder<Series>.CreateNew()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
.With(c => c.Monitored = true)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-07-09 01:22:02 +00:00
|
|
|
|
_firstEpisode = new Episode { Monitored = true };
|
|
|
|
|
_secondEpisode = new Episode { Monitored = true };
|
2013-04-15 01:41:39 +00:00
|
|
|
|
|
|
|
|
|
|
2013-04-15 03:33:03 +00:00
|
|
|
|
var singleEpisodeList = new List<Episode> { _firstEpisode };
|
|
|
|
|
var doubleEpisodeList = new List<Episode> { _firstEpisode, _secondEpisode };
|
|
|
|
|
|
|
|
|
|
_parseResultMulti = new RemoteEpisode
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-04-15 03:33:03 +00:00
|
|
|
|
Series = _fakeSeries,
|
2013-04-15 01:41:39 +00:00
|
|
|
|
Episodes = doubleEpisodeList
|
2012-02-07 05:08:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-04-15 03:33:03 +00:00
|
|
|
|
_parseResultSingle = new RemoteEpisode
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-04-15 03:33:03 +00:00
|
|
|
|
Series = _fakeSeries,
|
2013-04-15 01:41:39 +00:00
|
|
|
|
Episodes = singleEpisodeList
|
2012-02-07 05:08:07 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-09 01:22:02 +00:00
|
|
|
|
private void WithFirstEpisodeUnmonitored()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
|
_firstEpisode.Monitored = false;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-09 01:22:02 +00:00
|
|
|
|
private void WithSecondEpisodeUnmonitored()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
|
_secondEpisode.Monitored = false;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void setup_should_return_monitored_episode_should_return_true()
|
|
|
|
|
{
|
2014-10-27 05:51:50 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void not_monitored_series_should_be_skipped()
|
|
|
|
|
{
|
2013-04-15 03:33:03 +00:00
|
|
|
|
_fakeSeries.Monitored = false;
|
2014-10-27 05:51:50 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-07-09 01:22:02 +00:00
|
|
|
|
public void only_episode_not_monitored_should_return_false()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
|
WithFirstEpisodeUnmonitored();
|
2014-10-27 05:51:50 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-07-09 01:22:02 +00:00
|
|
|
|
public void both_episodes_not_monitored_should_return_false()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
|
WithFirstEpisodeUnmonitored();
|
|
|
|
|
WithSecondEpisodeUnmonitored();
|
2014-10-27 05:51:50 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2015-03-13 20:08:00 +00:00
|
|
|
|
public void only_first_episode_not_monitored_should_return_false()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
|
WithFirstEpisodeUnmonitored();
|
2015-03-13 20:08:00 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2015-03-13 20:08:00 +00:00
|
|
|
|
public void only_second_episode_not_monitored_should_return_false()
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
|
WithSecondEpisodeUnmonitored();
|
2015-03-13 20:08:00 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
2013-08-08 03:30:20 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
2015-02-11 01:19:15 +00:00
|
|
|
|
public void should_return_true_for_single_episode_search()
|
2013-08-08 03:30:20 +00:00
|
|
|
|
{
|
|
|
|
|
_fakeSeries.Monitored = false;
|
2015-02-11 01:19:15 +00:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_if_episode_is_monitored_for_season_search()
|
|
|
|
|
{
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_episode_is_not_monitored_for_season_search()
|
|
|
|
|
{
|
|
|
|
|
WithFirstEpisodeUnmonitored();
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeFalse();
|
2013-08-08 03:30:20 +00:00
|
|
|
|
}
|
2015-03-25 00:11:46 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false()
|
|
|
|
|
{
|
|
|
|
|
WithFirstEpisodeUnmonitored();
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true()
|
|
|
|
|
{
|
|
|
|
|
WithFirstEpisodeUnmonitored();
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse();
|
|
|
|
|
}
|
2017-04-29 00:37:18 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_all_episodes_are_not_monitored_for_season_pack_release()
|
|
|
|
|
{
|
|
|
|
|
WithSecondEpisodeUnmonitored();
|
|
|
|
|
_parseResultMulti.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
|
|
|
|
{
|
|
|
|
|
FullSeason = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
|
|
|
|
|
}
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|