2013-07-19 05:47:55 +02:00
|
|
|
|
using FluentAssertions;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using NUnit.Framework;
|
2013-08-12 08:00:40 +02:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-02-19 03:19:38 +01:00
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
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-03-28 23:07:09 +01:00
|
|
|
|
|
2013-03-07 01:19:49 +01:00
|
|
|
|
public class QualityUpgradeSpecificationFixture : CoreTest<QualityUpgradableSpecification>
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2012-10-14 02:36:16 +02:00
|
|
|
|
public static object[] IsUpgradeTestCases =
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
new object[] { Quality.SDTV, false, Quality.SDTV, true, Quality.SDTV, true },
|
|
|
|
|
new object[] { Quality.WEBDL720p, false, Quality.WEBDL720p, true, Quality.WEBDL720p, true },
|
|
|
|
|
new object[] { Quality.SDTV, false, Quality.SDTV, false, Quality.SDTV, false },
|
|
|
|
|
new object[] { Quality.WEBDL720p, false, Quality.HDTV720p, true, Quality.Bluray720p, false },
|
|
|
|
|
new object[] { Quality.WEBDL720p, false, Quality.HDTV720p, true, Quality.WEBDL720p, false },
|
|
|
|
|
new object[] { Quality.WEBDL720p, false, Quality.WEBDL720p, false, Quality.WEBDL720p, false },
|
|
|
|
|
new object[] { Quality.SDTV, false, Quality.SDTV, true, Quality.SDTV, true },
|
|
|
|
|
new object[] { Quality.WEBDL1080p, false, Quality.WEBDL1080p, false, Quality.WEBDL1080p, false }
|
2012-10-14 02:36:16 +02:00
|
|
|
|
};
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2013-08-12 08:00:40 +02:00
|
|
|
|
private void GivenAutoDownloadPropers(bool autoDownloadPropers)
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IConfigService>()
|
|
|
|
|
.SetupGet(s => s.AutoDownloadPropers)
|
|
|
|
|
.Returns(autoDownloadPropers);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
[Test, TestCaseSource("IsUpgradeTestCases")]
|
2013-02-27 04:19:22 +01:00
|
|
|
|
public void IsUpgradeTest(Quality current, bool currentProper, Quality newQuality, bool newProper, Quality cutoff, bool expected)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2013-08-12 08:00:40 +02:00
|
|
|
|
GivenAutoDownloadPropers(true);
|
|
|
|
|
|
2013-09-11 04:07:22 +02:00
|
|
|
|
Subject.IsUpgradable(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper))
|
2012-10-14 02:36:16 +02:00
|
|
|
|
.Should().Be(expected);
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
2013-08-12 08:00:40 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_proper_and_autoDownloadPropers_is_false()
|
|
|
|
|
{
|
|
|
|
|
GivenAutoDownloadPropers(false);
|
|
|
|
|
|
2013-09-11 04:07:22 +02:00
|
|
|
|
Subject.IsUpgradable(new QualityModel(Quality.DVD, true),
|
2013-08-12 08:00:40 +02:00
|
|
|
|
new QualityModel(Quality.DVD, false)).Should().BeFalse();
|
|
|
|
|
}
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|