2013-07-19 05:47:55 +02:00
|
|
|
|
using System.Collections.Generic;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
2013-04-29 03:47:06 +02:00
|
|
|
|
using Marr.Data;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
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-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
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 QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-04-28 21:46:13 +02:00
|
|
|
|
private RemoteEpisode remoteEpisode;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
public static object[] AllowedTestCases =
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
new object[] { Quality.DVD },
|
|
|
|
|
new object[] { Quality.HDTV720p },
|
|
|
|
|
new object[] { Quality.Bluray1080p }
|
2012-10-14 02:36:16 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static object[] DeniedTestCases =
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
new object[] { Quality.SDTV },
|
|
|
|
|
new object[] { Quality.WEBDL720p },
|
|
|
|
|
new object[] { Quality.Bluray720p }
|
2012-10-14 02:36:16 +02:00
|
|
|
|
};
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
2013-04-29 03:47:06 +02:00
|
|
|
|
.With(c => c.QualityProfile = (LazyLoaded<QualityProfile>)new QualityProfile { Cutoff = Quality.Bluray1080p })
|
2012-02-07 06:08:07 +01:00
|
|
|
|
.Build();
|
|
|
|
|
|
2013-04-28 21:46:13 +02:00
|
|
|
|
remoteEpisode = new RemoteEpisode
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
Series = fakeSeries,
|
2013-04-28 21:46:13 +02:00
|
|
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, true) },
|
2012-02-07 06:08:07 +01:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
[Test, TestCaseSource("AllowedTestCases")]
|
2013-02-27 04:19:22 +01:00
|
|
|
|
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-04-28 21:46:13 +02:00
|
|
|
|
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
2013-04-29 03:47:06 +02:00
|
|
|
|
remoteEpisode.Series.QualityProfile.Value.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2013-08-07 05:18:05 +02:00
|
|
|
|
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeTrue();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
[Test, TestCaseSource("DeniedTestCases")]
|
2013-02-27 04:19:22 +01:00
|
|
|
|
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-04-28 21:46:13 +02:00
|
|
|
|
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
2013-04-29 03:47:06 +02:00
|
|
|
|
remoteEpisode.Series.QualityProfile.Value.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2013-08-07 05:18:05 +02:00
|
|
|
|
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeFalse();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|