2013-04-15 05:33:03 +02:00
|
|
|
|
using System.Collections.Generic;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-03-07 01:19:49 +01:00
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2013-04-15 03:41:39 +02:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 03:19:38 +01:00
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-04-15 03:41:39 +02:00
|
|
|
|
|
|
|
|
|
public class MonitoredEpisodeSpecificationFixture : CoreTest<MonitoredEpisodeSpecification>
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
private MonitoredEpisodeSpecification _monitoredEpisodeSpecification;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2013-04-15 05:33:03 +02:00
|
|
|
|
private RemoteEpisode _parseResultMulti;
|
|
|
|
|
private RemoteEpisode _parseResultSingle;
|
|
|
|
|
private Series _fakeSeries;
|
|
|
|
|
private Episode _firstEpisode;
|
|
|
|
|
private Episode _secondEpisode;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_monitoredEpisodeSpecification = Mocker.Resolve<MonitoredEpisodeSpecification>();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_fakeSeries = Builder<Series>.CreateNew()
|
2012-02-07 06:08:07 +01:00
|
|
|
|
.With(c => c.Monitored = true)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_firstEpisode = new Episode { Ignored = false };
|
|
|
|
|
_secondEpisode = new Episode { Ignored = false };
|
2013-04-15 03:41:39 +02:00
|
|
|
|
|
|
|
|
|
|
2013-04-15 05:33:03 +02:00
|
|
|
|
var singleEpisodeList = new List<Episode> { _firstEpisode };
|
|
|
|
|
var doubleEpisodeList = new List<Episode> { _firstEpisode, _secondEpisode };
|
|
|
|
|
|
|
|
|
|
_parseResultMulti = new RemoteEpisode
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
Series = _fakeSeries,
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Episodes = doubleEpisodeList
|
2012-02-07 06:08:07 +01:00
|
|
|
|
};
|
|
|
|
|
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_parseResultSingle = new RemoteEpisode
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
Series = _fakeSeries,
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Episodes = singleEpisodeList
|
2012-02-07 06:08:07 +01:00
|
|
|
|
};
|
|
|
|
|
|
2013-04-15 05:33:03 +02:00
|
|
|
|
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithFirstEpisodeIgnored()
|
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_firstEpisode.Ignored = true;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithSecondEpisodeIgnored()
|
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_secondEpisode.Ignored = true;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void setup_should_return_monitored_episode_should_return_true()
|
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeTrue();
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void not_monitored_series_should_be_skipped()
|
|
|
|
|
{
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_fakeSeries.Monitored = false;
|
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void only_episode_ignored_should_return_false()
|
|
|
|
|
{
|
|
|
|
|
WithFirstEpisodeIgnored();
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void both_episodes_ignored_should_return_false()
|
|
|
|
|
{
|
|
|
|
|
WithFirstEpisodeIgnored();
|
|
|
|
|
WithSecondEpisodeIgnored();
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void only_first_episode_ignored_should_return_monitored()
|
|
|
|
|
{
|
|
|
|
|
WithFirstEpisodeIgnored();
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void only_second_episode_ignored_should_return_monitored()
|
|
|
|
|
{
|
|
|
|
|
WithSecondEpisodeIgnored();
|
2013-04-15 05:33:03 +02:00
|
|
|
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|