Radarr/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpec...

68 lines
2.3 KiB
C#
Raw Permalink Normal View History

using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
2019-12-22 22:08:53 +00:00
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
2023-08-15 02:20:03 +00:00
using NzbDrone.Core.Profiles.Qualities;
2013-02-27 03:19:22 +00:00
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
2013-02-19 02:19:38 +00:00
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
public class QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
{
2019-12-22 22:08:53 +00:00
private RemoteMovie _remoteMovie;
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
};
[SetUp]
public void Setup()
{
var fakeSeries = Builder<Movie>.CreateNew()
2023-08-15 02:20:03 +00:00
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p.Id })
.Build();
2019-12-22 22:08:53 +00:00
_remoteMovie = new RemoteMovie
{
Movie = fakeSeries,
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
};
}
2019-12-22 22:08:53 +00:00
[Test]
[TestCaseSource("AllowedTestCases")]
2013-02-27 03:19:22 +00:00
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
{
2019-12-22 22:08:53 +00:00
_remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
2023-08-15 02:20:03 +00:00
_remoteMovie.Movie.QualityProfile.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
2019-12-22 22:08:53 +00:00
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
2019-12-22 22:08:53 +00:00
[Test]
[TestCaseSource("DeniedTestCases")]
2013-02-27 03:19:22 +00:00
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
{
2019-12-22 22:08:53 +00:00
_remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
2023-08-15 02:20:03 +00:00
_remoteMovie.Movie.QualityProfile.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
2019-12-22 22:08:53 +00:00
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
}
}