2012-02-07 08:08:07 +03:00
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
2013-03-07 03:19:49 +03:00
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2013-02-27 06:19:22 +03:00
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-19 09:01:03 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-07 08:08:07 +03:00
|
|
|
using NzbDrone.Core.Model;
|
2013-02-19 05:19:38 +03:00
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2013-03-07 04:51:47 +03:00
|
|
|
|
2012-02-07 08:08:07 +03:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
2013-02-19 05:19:38 +03:00
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-17 08:44:06 +03:00
|
|
|
public class QualityAllowedByProfileSpecificationFixture : CoreTest
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
|
|
|
private QualityAllowedByProfileSpecification _qualityAllowedByProfile;
|
|
|
|
private EpisodeParseResult parseResult;
|
|
|
|
|
2012-10-14 03:36:16 +03:00
|
|
|
public static object[] AllowedTestCases =
|
|
|
|
{
|
2013-02-27 06:19:22 +03:00
|
|
|
new object[] { Quality.DVD },
|
|
|
|
new object[] { Quality.HDTV720p },
|
|
|
|
new object[] { Quality.Bluray1080p }
|
2012-10-14 03:36:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
public static object[] DeniedTestCases =
|
|
|
|
{
|
2013-02-27 06:19:22 +03:00
|
|
|
new object[] { Quality.SDTV },
|
|
|
|
new object[] { Quality.WEBDL720p },
|
|
|
|
new object[] { Quality.Bluray720p }
|
2012-10-14 03:36:16 +03:00
|
|
|
};
|
2012-02-07 08:08:07 +03:00
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
_qualityAllowedByProfile = Mocker.Resolve<QualityAllowedByProfileSpecification>();
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
2013-02-27 06:19:22 +03:00
|
|
|
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
|
2012-02-07 08:08:07 +03:00
|
|
|
.Build();
|
|
|
|
|
|
|
|
parseResult = new EpisodeParseResult
|
|
|
|
{
|
|
|
|
Series = fakeSeries,
|
2013-02-27 06:19:22 +03:00
|
|
|
Quality = new QualityModel(Quality.DVD, true),
|
2012-02-07 08:08:07 +03:00
|
|
|
EpisodeNumbers = new List<int> { 3 },
|
|
|
|
SeasonNumber = 12,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-10-14 03:36:16 +03:00
|
|
|
[Test, TestCaseSource("AllowedTestCases")]
|
2013-02-27 06:19:22 +03:00
|
|
|
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2012-10-14 03:36:16 +03:00
|
|
|
parseResult.Quality.Quality = qualityType;
|
2013-02-27 06:19:22 +03:00
|
|
|
parseResult.Series.QualityProfile.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
|
2012-02-07 08:08:07 +03:00
|
|
|
|
|
|
|
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
}
|
|
|
|
|
2012-10-14 03:36:16 +03:00
|
|
|
[Test, TestCaseSource("DeniedTestCases")]
|
2013-02-27 06:19:22 +03:00
|
|
|
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2012-10-14 03:36:16 +03:00
|
|
|
parseResult.Quality.Quality = qualityType;
|
2013-02-27 06:19:22 +03:00
|
|
|
parseResult.Series.QualityProfile.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
|
2012-02-07 08:08:07 +03:00
|
|
|
|
|
|
|
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeFalse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|