2021-08-03 04:43:28 +00:00
|
|
|
using FizzWare.NBuilder;
|
2012-02-07 05:08:07 +00:00
|
|
|
using FluentAssertions;
|
2013-04-29 01:47:06 +00:00
|
|
|
using Marr.Data;
|
2012-02-07 05:08:07 +00:00
|
|
|
using NUnit.Framework;
|
2013-03-07 00:19:49 +00:00
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2013-04-15 01:41:39 +00:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2015-07-12 16:44:33 +00:00
|
|
|
using NzbDrone.Core.Profiles.Qualities;
|
2013-02-27 03:19:22 +00:00
|
|
|
using NzbDrone.Core.Qualities;
|
2012-02-07 05:08:07 +00:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
2021-08-03 04:43:28 +00:00
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
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 QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2021-08-03 04:43:28 +00:00
|
|
|
private RemoteEpisode _remoteEpisode;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
2012-10-14 00:36:16 +00:00
|
|
|
public static object[] AllowedTestCases =
|
|
|
|
{
|
2013-02-27 03:19:22 +00:00
|
|
|
new object[] { Quality.DVD },
|
|
|
|
new object[] { Quality.HDTV720p },
|
|
|
|
new object[] { Quality.Bluray1080p }
|
2012-10-14 00:36:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public static object[] DeniedTestCases =
|
|
|
|
{
|
2013-02-27 03:19:22 +00:00
|
|
|
new object[] { Quality.SDTV },
|
|
|
|
new object[] { Quality.WEBDL720p },
|
|
|
|
new object[] { Quality.Bluray720p }
|
2012-10-14 00:36:16 +00:00
|
|
|
};
|
2012-02-07 05:08:07 +00:00
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
2018-11-29 04:26:49 +00:00
|
|
|
.With(c => c.QualityProfile = (LazyLoaded<QualityProfile>)new QualityProfile { Cutoff = Quality.Bluray1080p.Id })
|
2012-02-07 05:08:07 +00:00
|
|
|
.Build();
|
|
|
|
|
2021-08-03 04:43:28 +00:00
|
|
|
_remoteEpisode = new RemoteEpisode
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
|
|
|
Series = fakeSeries,
|
2014-09-01 02:28:42 +00:00
|
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
2012-02-07 05:08:07 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-08-03 04:43:28 +00:00
|
|
|
[Test]
|
|
|
|
[TestCaseSource(nameof(AllowedTestCases))]
|
2013-02-27 03:19:22 +00:00
|
|
|
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2021-08-03 04:43:28 +00:00
|
|
|
_remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
|
|
|
_remoteEpisode.Series.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
2012-02-07 05:08:07 +00:00
|
|
|
|
2021-08-03 04:43:28 +00:00
|
|
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
2012-02-07 05:08:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-03 04:43:28 +00:00
|
|
|
[Test]
|
|
|
|
[TestCaseSource(nameof(DeniedTestCases))]
|
2013-02-27 03:19:22 +00:00
|
|
|
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2021-08-03 04:43:28 +00:00
|
|
|
_remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
|
|
|
_remoteEpisode.Series.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
|
2012-02-07 05:08:07 +00:00
|
|
|
|
2021-08-03 04:43:28 +00:00
|
|
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
2012-02-07 05:08:07 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-03 04:43:28 +00:00
|
|
|
}
|