2012-02-07 06:08:07 +01:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers.DecisionEngine;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-02 21:54:03 +01:00
|
|
|
|
public class QualityAllowedByProfileSpecificationFixture : SqlCeTest
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
private QualityAllowedByProfileSpecification _qualityAllowedByProfile;
|
|
|
|
|
private EpisodeParseResult parseResult;
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
public static object[] AllowedTestCases =
|
|
|
|
|
{
|
|
|
|
|
new object[] { QualityTypes.DVD },
|
2013-01-01 04:45:57 +01:00
|
|
|
|
new object[] { QualityTypes.HDTV720p },
|
2012-10-14 02:36:16 +02:00
|
|
|
|
new object[] { QualityTypes.Bluray1080p }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static object[] DeniedTestCases =
|
|
|
|
|
{
|
|
|
|
|
new object[] { QualityTypes.SDTV },
|
2012-10-15 06:30:07 +02:00
|
|
|
|
new object[] { QualityTypes.WEBDL720p },
|
2012-10-14 02:36:16 +02:00
|
|
|
|
new object[] { QualityTypes.Bluray720p }
|
|
|
|
|
};
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_qualityAllowedByProfile = Mocker.Resolve<QualityAllowedByProfileSpecification>();
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.QualityProfile = new QualityProfile { Cutoff = QualityTypes.Bluray1080p })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
parseResult = new EpisodeParseResult
|
|
|
|
|
{
|
|
|
|
|
Series = fakeSeries,
|
2012-10-13 23:15:21 +02:00
|
|
|
|
Quality = new QualityModel(QualityTypes.DVD, true),
|
2012-02-07 06:08:07 +01:00
|
|
|
|
EpisodeNumbers = new List<int> { 3 },
|
|
|
|
|
SeasonNumber = 12,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
[Test, TestCaseSource("AllowedTestCases")]
|
2012-02-07 06:08:07 +01:00
|
|
|
|
public void should_allow_if_quality_is_defined_in_profile(QualityTypes qualityType)
|
|
|
|
|
{
|
2012-10-14 02:36:16 +02:00
|
|
|
|
parseResult.Quality.Quality = qualityType;
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.Series.QualityProfile.Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.HDTV720p, QualityTypes.Bluray1080p };
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
[Test, TestCaseSource("DeniedTestCases")]
|
2012-02-07 06:08:07 +01:00
|
|
|
|
public void should_not_allow_if_quality_is_not_defined_in_profile(QualityTypes qualityType)
|
|
|
|
|
{
|
2012-10-14 02:36:16 +02:00
|
|
|
|
parseResult.Quality.Quality = qualityType;
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.Series.QualityProfile.Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.HDTV720p, QualityTypes.Bluray1080p };
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|