QualityTypes no longer an enum

This commit is contained in:
Mark McDowall 2012-10-13 17:36:16 -07:00
parent 49f086cf19
commit 92acb4c049
37 changed files with 585 additions and 247 deletions

View File

@ -138,10 +138,14 @@ namespace NzbDrone.Core.Test
ExceptionVerification.IgnoreWarns();
}
[TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)]
public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality)
[Test]
public void custome_parser_partial_success()
{
const string title = "Adventure.Inc.S03E19.DVDRip.XviD-OSiTV";
const int season = 3;
const int episode = 19;
var quality = QualityTypes.DVD;
const string summary = "My fake summary";
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
@ -160,10 +164,9 @@ namespace NzbDrone.Core.Test
Assert.AreEqual(LanguageType.Finnish, result.Language);
Assert.AreEqual(season, result.SeasonNumber);
Assert.AreEqual(episode, result.EpisodeNumbers[0]);
Assert.AreEqual(quality, result.Quality.QualityType);
Assert.AreEqual(quality, result.Quality.Quality);
}
[TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")]
public void custome_parser_full_parse(string title)
{

View File

@ -137,12 +137,14 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="QualityTypesTest.cs" />
<Compile Include="EpisodeParseResultTest.cs" />
<Compile Include="Integeration\ServiceIntegerationFixture.cs" />
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
<Compile Include="JobTests\RssSyncJobTest.cs" />
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
<Compile Include="ParserFixture\QualityParserTests.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigCachingFixture.cs" />
<Compile Include="ProviderTests\BannerProviderTest.cs" />
<Compile Include="ProviderTests\DecisionEngineTests\AllowedReleaseGroupSpecificationFixture.cs" />
@ -226,7 +228,7 @@
<Compile Include="ProviderTests\ConfigProviderTests\ConfigProviderFixture.cs" />
<Compile Include="ProviderTests\EpisodeProviderTest.cs" />
<Compile Include="Framework\TestDbHelper.cs" />
<Compile Include="ParserTest.cs" />
<Compile Include="ParserFixture\ParserTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QualityProfileTest.cs" />
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" />

View File

@ -11,7 +11,7 @@ using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test
namespace NzbDrone.Core.Test.ParserFixture
{
[TestFixture]
// ReSharper disable InconsistentNaming
@ -126,73 +126,6 @@ namespace NzbDrone.Core.Test
ExceptionVerification.IgnoreWarns();
}
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD, false)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD, false)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD, false)]
[TestCase("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV, false)]
[TestCase("this has no extention or periods HDTV", QualityTypes.SDTV, false)]
[TestCase("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV, false)]
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD, false)]
[TestCase("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD, false)]
[TestCase("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV, false)]
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV, false)]
[TestCase("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL, false)]
[TestCase("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV, false)]
[TestCase("Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV, false)]
[TestCase("Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV, false)]
[TestCase("Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV, false)]
[TestCase("Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV, false)]
[TestCase("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown, false)]
[TestCase("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV, false)]
[TestCase("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV, false)]
[TestCase("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p, false)]
[TestCase("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p, false)]
[TestCase("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL, false)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)]
[TestCase("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown, false)]
[TestCase("(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown, false)]
[TestCase("S07E23 - [HDTV].mkv ", QualityTypes.HDTV, false)]
[TestCase("S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL, false)]
[TestCase("S07E23.mkv ", QualityTypes.HDTV, false)]
[TestCase("S07E23 .avi ", QualityTypes.SDTV, false)]
[TestCase("WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)]
[TestCase("WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p, false)]
[TestCase("The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.Unknown, false)]
[TestCase("Nikita S02E01 HDTV XviD 2HD", QualityTypes.SDTV, false)]
[TestCase("Gossip Girl S05E11 PROPER HDTV XviD 2HD", QualityTypes.SDTV, true)]
[TestCase("The Jonathan Ross Show S02E08 HDTV x264 FTP", QualityTypes.SDTV, false)]
[TestCase("White.Van.Man.2011.S02E01.WS.PDTV.x264-TLA", QualityTypes.SDTV, false)]
[TestCase("White.Van.Man.2011.S02E01.WS.PDTV.x264-REPACK-TLA", QualityTypes.SDTV, true)]
[TestCase("WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3-REPACK.-HELLYWOOD.avi", QualityTypes.DVD, true)]
[TestCase("Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", QualityTypes.HDTV, true)]
[TestCase("The Real Housewives of Vancouver S01E04 DSR x264 2HD", QualityTypes.SDTV, false)]
[TestCase("Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", QualityTypes.SDTV, false)]
[TestCase("Vanguard S01E04 Mexicos Death Train 720 WEB DL", QualityTypes.WEBDL, false)]
[TestCase("Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", QualityTypes.WEBDL, false)]
[TestCase("Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL, false)]
[TestCase("Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", QualityTypes.WEBDL, false)]
[TestCase("Fringe.S04E22.720p.WEB.DL.DD5.1.H264-EbP", QualityTypes.WEBDL, false)]
public void quality_parse(string postTitle, object quality, bool proper)
{
var result = Parser.ParseQuality(postTitle);
result.QualityType.Should().Be(quality);
result.Proper.Should().Be(proper);
}
[Test]
public void parsing_our_own_quality_enum()
{
var qualityEnums = Enum.GetValues(typeof(QualityTypes));
foreach (var qualityEnum in qualityEnums)
{
var fileName = String.Format("My series S01E01 [{0}]", qualityEnum);
var result = Parser.ParseQuality(fileName);
result.QualityType.Should().Be(qualityEnum);
}
}
//[Timeout(1000)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1, 2, 3, 4, 5, 6 })]
[TestCase("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Men", 1, new[] { 3, 4 })]

View File

@ -0,0 +1,97 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Contract;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.ParserFixture
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityParserTests : CoreTest
{
public static object[] QualityParserCases =
{
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD, false },
new object[] { "Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV, false },
new object[] { "this has no extention or periods HDTV", QualityTypes.SDTV, false },
new object[] { "Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV, false },
new object[] { "The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV, false },
new object[] { "Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL, false },
new object[] { "Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15", QualityTypes.Unknown, false },
new object[] { "Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV, false },
new object[] { "Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV, false },
new object[] { "Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p, false },
new object[] { "Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p, false },
new object[] { "Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false },
new object[] { "Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown, false },
new object[] { "(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown, false },
new object[] { "S07E23 - [HDTV].mkv ", QualityTypes.HDTV, false },
new object[] { "S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL, false },
new object[] { "S07E23.mkv ", QualityTypes.HDTV, false },
new object[] { "S07E23 .avi ", QualityTypes.SDTV, false },
new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p, false },
new object[] { "The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.Unknown, false },
new object[] { "Nikita S02E01 HDTV XviD 2HD", QualityTypes.SDTV, false },
new object[] { "Gossip Girl S05E11 PROPER HDTV XviD 2HD", QualityTypes.SDTV, true },
new object[] { "The Jonathan Ross Show S02E08 HDTV x264 FTP", QualityTypes.SDTV, false },
new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-TLA", QualityTypes.SDTV, false },
new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-REPACK-TLA", QualityTypes.SDTV, true },
new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3-REPACK.-HELLYWOOD.avi", QualityTypes.DVD, true },
new object[] { "Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", QualityTypes.HDTV, true },
new object[] { "The Real Housewives of Vancouver S01E04 DSR x264 2HD", QualityTypes.SDTV, false },
new object[] { "Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", QualityTypes.SDTV, false },
new object[] { "Vanguard S01E04 Mexicos Death Train 720 WEB DL", QualityTypes.WEBDL, false },
new object[] { "Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", QualityTypes.WEBDL, false },
new object[] { "Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL, false },
new object[] { "Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", QualityTypes.WEBDL, false },
new object[] { "Fringe.S04E22.720p.WEB.DL.DD5.1.H264-EbP", QualityTypes.WEBDL, false }
};
public static object[] SelfQualityParserCases =
{
new object[] { QualityTypes.SDTV },
new object[] { QualityTypes.DVD },
new object[] { QualityTypes.HDTV },
new object[] { QualityTypes.WEBDL },
new object[] { QualityTypes.Bluray720p },
new object[] { QualityTypes.Bluray1080p }
};
[Test, TestCaseSource("QualityParserCases")]
public void quality_parse(string postTitle, QualityTypes quality, bool proper)
{
var result = Parser.ParseQuality(postTitle);
result.Quality.Should().Be(quality);
result.Proper.Should().Be(proper);
}
[Test, TestCaseSource("SelfQualityParserCases")]
public void parsing_our_own_quality_enum(QualityTypes quality)
{
var fileName = String.Format("My series S01E01 [{0}]", quality);
var result = Parser.ParseQuality(fileName);
result.Quality.Should().Be(quality);
}
}
}

View File

@ -18,10 +18,21 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
public class QualityAllowedByProfileSpecificationFixtrue : CoreTest
{
private QualityAllowedByProfileSpecification _qualityAllowedByProfile;
private EpisodeParseResult parseResult;
public static object[] AllowedTestCases =
{
new object[] { QualityTypes.DVD },
new object[] { QualityTypes.HDTV },
new object[] { QualityTypes.Bluray1080p }
};
public static object[] DeniedTestCases =
{
new object[] { QualityTypes.SDTV },
new object[] { QualityTypes.WEBDL },
new object[] { QualityTypes.Bluray720p }
};
[SetUp]
public void Setup()
@ -41,29 +52,22 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
};
}
[TestCase(QualityTypes.DVD)]
[TestCase(QualityTypes.HDTV)]
[TestCase(QualityTypes.Bluray1080p)]
[Test, TestCaseSource("AllowedTestCases")]
public void should_allow_if_quality_is_defined_in_profile(QualityTypes qualityType)
{
parseResult.Quality.QualityType = qualityType;
parseResult.Quality.Quality = qualityType;
parseResult.Series.QualityProfile.Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.HDTV, QualityTypes.Bluray1080p };
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeTrue();
}
[TestCase(QualityTypes.SDTV)]
[TestCase(QualityTypes.WEBDL)]
[TestCase(QualityTypes.Bluray720p)]
[Test, TestCaseSource("DeniedTestCases")]
public void should_not_allow_if_quality_is_not_defined_in_profile(QualityTypes qualityType)
{
parseResult.Quality.QualityType = qualityType;
parseResult.Quality.Quality = qualityType;
parseResult.Series.QualityProfile.Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.HDTV, QualityTypes.Bluray1080p };
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeFalse();
}
}
}

View File

@ -1,6 +1,7 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.DecisionEngine;
@ -13,18 +14,23 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
// ReSharper disable InconsistentNaming
public class QualityUpgradeSpecificationFixture : CoreTest
{
[TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, Result = true)]
[TestCase(QualityTypes.WEBDL, false, QualityTypes.WEBDL, true, QualityTypes.WEBDL, Result = true)]
[TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, false, QualityTypes.SDTV, Result = false)]
[TestCase(QualityTypes.SDTV, false, QualityTypes.DVD, true, QualityTypes.SDTV, Result = false)]
[TestCase(QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.Bluray720p, Result = false)]
[TestCase(QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.WEBDL, Result = false)]
[TestCase(QualityTypes.WEBDL, false, QualityTypes.WEBDL, false, QualityTypes.WEBDL, Result = false)]
[TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, Result = true)]
public bool IsUpgradeTest(QualityTypes current, bool currentProper, QualityTypes newQuality, bool newProper, QualityTypes cutoff)
public static object[] IsUpgradeTestCases =
{
return new QualityUpgradeSpecification().IsSatisfiedBy(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper), cutoff);
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true },
new object[] { QualityTypes.WEBDL, false, QualityTypes.WEBDL, true, QualityTypes.WEBDL, true },
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, false, QualityTypes.SDTV, false },
new object[] { QualityTypes.SDTV, false, QualityTypes.DVD, true, QualityTypes.SDTV, false },
new object[] { QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.Bluray720p, false },
new object[] { QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.WEBDL, false },
new object[] { QualityTypes.WEBDL, false, QualityTypes.WEBDL, false, QualityTypes.WEBDL, false },
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true }
};
[Test, TestCaseSource("IsUpgradeTestCases")]
public void IsUpgradeTest(QualityTypes current, bool currentProper, QualityTypes newQuality, bool newProper, QualityTypes cutoff, bool expected)
{
new QualityUpgradeSpecification().IsSatisfiedBy(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper), cutoff)
.Should().Be(expected);
}
}
}

View File

@ -71,12 +71,12 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
private void WithFirstReportUpgradable()
{
firstQuality.QualityType = QualityTypes.SDTV;
firstQuality.Quality = QualityTypes.SDTV;
}
private void WithSecondReportUpgradable()
{
secondQuality.QualityType = QualityTypes.SDTV;
secondQuality.Quality = QualityTypes.SDTV;
}

View File

@ -20,6 +20,13 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
// ReSharper disable InconsistentNaming
public class ImportFileFixture : CoreTest
{
public static object[] ImportTestCases =
{
new object[] { QualityTypes.SDTV },
new object[] { QualityTypes.DVD },
new object[] { QualityTypes.HDTV }
};
[Test]
public void import_new_file_should_succeed()
{
@ -49,9 +56,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
}
[TestCase(QualityTypes.SDTV, false)]
[TestCase(QualityTypes.DVD, true)]
[TestCase(QualityTypes.HDTV, false)]
[Test, TestCaseSource("ImportTestCases")]
public void import_new_file_with_better_same_quality_should_succeed(QualityTypes currentFileQuality, bool currentFileProper)
{
const string newFile = @"WEEDS.S03E01.DUAL.1080p.HELLYWOOD.mkv";
@ -262,9 +267,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Build())
.Build();
//Mocks
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();

View File

@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fi);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel{ QualityType = QualityTypes.WEBDL, Proper = false })))
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel{ Quality = QualityTypes.WEBDL, Proper = false })))
.Returns(message);
Mocker.GetMock<ExternalNotificationProvider>()

View File

@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 5 },
SeasonNumber = 1,
Quality = new QualityModel { QualityType = QualityTypes.SDTV, Proper = false },
Quality = new QualityModel { Quality = QualityTypes.SDTV, Proper = false },
Series = new Series { Title = "30 Rock", CleanTitle = Parser.NormalizeTitle("30 Rock") },
};
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
var parseResult = new EpisodeParseResult
{
Quality = new QualityModel { QualityType = QualityTypes.Bluray720p, Proper = false },
Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false },
AirDate = new DateTime(2011, 12, 01),
Series = new Series { Title = "The Dailyshow", CleanTitle = Parser.NormalizeTitle("The Dailyshow"), IsDaily = true },
};
@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
var parseResult = new EpisodeParseResult
{
Quality = new QualityModel { QualityType = QualityTypes.Bluray720p, Proper = false },
Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false },
FullSeason = true,
SeasonNumber = 5,
Series = new Series { Title = "My Name is earl", CleanTitle = Parser.NormalizeTitle("My Name is earl") },
@ -175,13 +175,18 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
result.Should().BeTrue();
}
[TestCase(2, new[] { 5 }, "30 Rock", QualityTypes.Bluray1080p, true, Description = "Same Series, Different Season, Episode")]
[TestCase(1, new[] { 6 }, "30 Rock", QualityTypes.Bluray1080p, true, Description = "Same series, different episodes")]
[TestCase(1, new[] { 6, 7, 8 }, "30 Rock", QualityTypes.Bluray1080p, true, Description = "Same series, different episodes")]
[TestCase(1, new[] { 6 }, "Some other show", QualityTypes.Bluray1080p, true, Description = "Different series, same season, episode")]
[TestCase(1, new[] { 5 }, "Rock", QualityTypes.Bluray1080p, true, Description = "Similar series, same season, episodes")]
[TestCase(1, new[] { 5 }, "30 Rock", QualityTypes.Bluray720p, false, Description = "Same series, higher quality")]
[TestCase(1, new[] { 5 }, "30 Rock", QualityTypes.HDTV, true, Description = "Same series, higher quality")]
public static object[] DifferentEpisodeCases =
{
new object[] { 2, new[] { 5 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same Series, Different Season, Episode
new object[] { 1, new[] { 6 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same series, different episodes
new object[] { 1, new[] { 6, 7, 8 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same series, different episodes
new object[] { 1, new[] { 6 }, "Some other show", QualityTypes.Bluray1080p, true }, //Different series, same season, episode
new object[] { 1, new[] { 5 }, "Rock", QualityTypes.Bluray1080p, true }, //Similar series, same season, episodes
new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.Bluray720p, false }, //Same series, higher quality
new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.HDTV, true } //Same series, higher quality
};
[Test, TestCaseSource("DifferentEpisodeCases")]
public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
{
WithFullQueue();
@ -191,7 +196,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new QualityModel { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -200,12 +205,17 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
result.Should().BeFalse();
}
[TestCase(1, new[] { 5 }, "30 Rock", QualityTypes.SDTV, false, Description = "Same Series, lower quality")]
[TestCase(1, new[] { 5 }, "30 rocK", QualityTypes.SDTV, false, Description = "Same Series, different casing")]
[TestCase(1, new[] { 5 }, "30 RocK", QualityTypes.HDTV, false, Description = "Same Series, same quality")]
[TestCase(1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false, Description = "Same Series, same quality, one different episode")]
[TestCase(1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false, Description = "Same Series, same quality, one different episode")]
[TestCase(4, new[] { 8 }, "Parks and Recreation", QualityTypes.WEBDL, false, Description = "Same Series, same quality")]
public static object[] LowerQualityCases =
{
new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.SDTV, false }, //Same Series, lower quality
new object[] { 1, new[] { 5 }, "30 rocK", QualityTypes.SDTV, false }, //Same Series, different casing
new object[] { 1, new[] { 5 }, "30 RocK", QualityTypes.HDTV, false }, //Same Series, same quality
new object[] { 1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false }, //Same Series, same quality, one different episode
new object[] { 1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false }, //Same Series, same quality, one different episode
new object[] { 4, new[] { 8 }, "Parks and Recreation", QualityTypes.WEBDL }, false, //Same Series, same quality
};
[Test, TestCaseSource("LowerQualityCases")]
public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
{
WithFullQueue();
@ -215,7 +225,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new QualityModel { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -224,10 +234,15 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
result.Should().BeTrue();
}
[TestCase(5, new[] { 13 }, "The Big Bang Theory", QualityTypes.SDTV, false, Description = "Same Series, lower quality")]
[TestCase(5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, false, Description = "Same Series, same quality")]
[TestCase(5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, true, Description = "Same Series, same quality")]
[TestCase(5, new[] { 13, 14 }, "The Big Bang Theory", QualityTypes.HDTV, false, Description = "Same Series, same quality, one diffrent episode")]
public static object[] DuplicateItemsCases =
{
new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.SDTV, false }, //Same Series, lower quality
new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, false }, //Same Series, same quality
new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, true }, //Same Series, same quality
new object[] { 5, new[] { 13, 14 }, "The Big Bang Theory", QualityTypes.HDTV, false } //Same Series, same quality, one diffrent episode
};
[Test, TestCaseSource("DuplicateItemsCases")]
public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
{
WithFullQueue();
@ -237,7 +252,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new QualityModel { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -246,10 +261,15 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
result.Should().BeTrue();
}
[TestCase(3, new[] { 14, 15 }, "My Name Is Earl", QualityTypes.Bluray720p, false)]
[TestCase(3, new[] { 15 }, "My Name Is Earl", QualityTypes.DVD, false)]
[TestCase(3, new[] { 14 }, "My Name Is Earl", QualityTypes.HDTV, false)]
[TestCase(3, new[] { 15, 16 }, "My Name Is Earl", QualityTypes.SDTV, false)]
public static object[] DoubleEpisodeCases =
{
new object[] { 3, new[] { 14, 15 }, "My Name Is Earl", QualityTypes.Bluray720p, false },
new object[] { 3, new[] { 15 }, "My Name Is Earl", QualityTypes.DVD, false },
new object[] { 3, new[] { 14 }, "My Name Is Earl", QualityTypes.HDTV, false },
new object[] { 3, new[] { 15, 16 }, "My Name Is Earl", QualityTypes.SDTV, false }
};
[Test, TestCaseSource("DoubleEpisodeCases")]
public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
{
WithFullQueue();
@ -259,7 +279,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new QualityModel { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -278,7 +298,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 1 },
SeasonNumber = 2,
Quality = new QualityModel { QualityType = QualityTypes.Bluray1080p, Proper = true },
Quality = new QualityModel { Quality = QualityTypes.Bluray1080p, Proper = true },
Series = new Series { Title = "Test", CleanTitle = Parser.NormalizeTitle("Test") },
};

View File

@ -20,6 +20,15 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestFixture]
public class DownloadProviderFixture : CoreTest
{
public static object[] SabNamingCases =
{
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
new object[] { 1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, "My Series Name - 1x02-1x04 - [HDTV] [Proper]" },
};
private void SetDownloadClient(DownloadClientType clientType)
{
@ -68,7 +77,6 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(false);
}
[Test]
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
{
@ -162,8 +170,6 @@ namespace NzbDrone.Core.Test.ProviderTests
.Verify(c => c.OnGrab(It.IsAny<String>()), Times.Never());
}
[Test]
public void should_return_sab_as_active_client()
{
@ -178,14 +184,8 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.Resolve<DownloadProvider>().GetActiveDownloadClient().Should().BeAssignableTo<BlackholeProvider>();
}
[TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, Result = "My Series Name - 1x02 - My Episode Title [DVD]")]
[TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, Result = "My Series Name - 1x02 - My Episode Title [DVD] [Proper]")]
[TestCase(1, new[] { 2 }, "", QualityTypes.DVD, true, Result = "My Series Name - 1x02 - [DVD] [Proper]")]
[TestCase(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false, Result = "My Series Name - 1x02-1x04 - My Episode Title [HDTV]")]
[TestCase(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true, Result = "My Series Name - 1x02-1x04 - My Episode Title [HDTV] [Proper]")]
[TestCase(1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, Result = "My Series Name - 1x02-1x04 - [HDTV] [Proper]")]
public string create_proper_sab_titles(int seasons, int[] episodes, string title, QualityTypes quality, bool proper)
[Test, TestCaseSource("SabNamingCases")]
public void create_proper_sab_titles(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string expected)
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.ProviderTests
EpisodeTitle = title
};
return Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult);
Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult).Should().Be(expected);
}
[TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")]

View File

@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.ProviderTests
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
@ -858,7 +858,7 @@ namespace NzbDrone.Core.Test.ProviderTests
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
@ -902,7 +902,7 @@ namespace NzbDrone.Core.Test.ProviderTests
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
@ -1224,6 +1224,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(c => c.EpisodeFileId = 1)
.With(c => c.Quality = QualityTypes.SDTV)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)

View File

@ -19,7 +19,10 @@ namespace NzbDrone.Core.Test.ProviderTests
{
WithRealDb();
//Setup
var historyItem = Builder<History>.CreateListOfSize(10).Build();
var historyItem = Builder<History>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.Build();
Db.InsertMany(historyItem);
@ -39,7 +42,15 @@ namespace NzbDrone.Core.Test.ProviderTests
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
var historyItems = Builder<History>.CreateListOfSize(10).TheFirst(5).With(h => h.SeriesId = seriesOne.SeriesId).TheLast(5).With(h => h.SeriesId = seriesTwo.SeriesId).Build();
var historyItems = Builder<History>
.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.TheFirst(5)
.With(h => h.SeriesId = seriesOne.SeriesId)
.TheLast(5)
.With(h => h.SeriesId = seriesTwo.SeriesId)
.Build();
Db.InsertMany(historyItems);
@ -65,7 +76,11 @@ namespace NzbDrone.Core.Test.ProviderTests
{
WithRealDb();
var historyItem = Builder<History>.CreateListOfSize(10).Build();
var historyItem = Builder<History>
.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.Build();
Db.InsertMany(historyItem);
//Act
@ -82,6 +97,8 @@ namespace NzbDrone.Core.Test.ProviderTests
WithRealDb();
var historyItem = Builder<History>.CreateListOfSize(30)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.TheFirst(10).With(c => c.Date = DateTime.Now)
.TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31))
.Build();
@ -129,7 +146,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//Assert
result.Should().NotBeNull();
result.QualityType.Should().Be(QualityTypes.Bluray720p);
result.Quality.Should().Be(QualityTypes.Bluray720p);
result.Proper.Should().BeTrue();
}
@ -184,7 +201,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//Assert
result.Should().NotBeNull();
result.QualityType.Should().Be(QualityTypes.Bluray720p);
result.Quality.Should().Be(QualityTypes.Bluray720p);
result.Proper.Should().BeTrue();
}
@ -195,7 +212,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var episode = Builder<Episode>.CreateNew().Build();
const QualityTypes quality = QualityTypes.HDTV;
QualityTypes quality = QualityTypes.HDTV;
const bool proper = true;
var history = new History

View File

@ -12,6 +12,7 @@ using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
@ -25,10 +26,14 @@ namespace NzbDrone.Core.Test.ProviderTests
public void get_series_files()
{
var firstSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All().With(s => s.SeriesId = 12).Build();
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(s => s.SeriesId = 12).Build();
var secondSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All().With(s => s.SeriesId = 20).Build();
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(s => s.SeriesId = 20).Build();
@ -51,12 +56,14 @@ namespace NzbDrone.Core.Test.ProviderTests
{
var firstSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(s => s.SeriesId = 12)
.With(s => s.SeasonNumber = 1)
.Build();
var secondSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(s => s.SeriesId = 12)
.With(s => s.SeasonNumber = 2)
.Build();
@ -143,7 +150,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void DeleteEpisodeFile()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10).Build();
var episodeFiles = Builder<EpisodeFile>
.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.Build();
var database = TestDbHelper.GetEmptyDatabase();
@ -180,6 +191,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//Setup
WithRealDb();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(c => c.Quality = QualityTypes.SDTV)
.With(f => f.Path = path.NormalizePath())
.Build();

View File

@ -9,6 +9,7 @@ using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
@ -116,7 +117,11 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
public void DeleteOrphanedEpisodeFiles()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10).Build();
var episodeFiles = Builder<EpisodeFile>
.CreateListOfSize(10)
.All()
.With(e => e.Quality = QualityTypes.DVD)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
Db.InsertMany(episodes);

View File

@ -37,6 +37,8 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.Build().ToList();
_searchHistory = Builder<SearchHistory>.CreateNew()
@ -77,6 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(i => i.Id == searchHistory.Id)
.Build();
@ -97,6 +100,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(i => i.Id == searchHistory.Id)
.Build();

View File

@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithSuccessfulDownload();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
.Returns(ReportRejectionType.None);
//Act
@ -221,11 +221,11 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithQualityNeeded();
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.DVD)))
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.DVD)))
.Returns(false);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.SDTV)))
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.SDTV)))
.Returns(true);
//Act

View File

@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithSuccessfulDownload();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
.Returns(ReportRejectionType.None);
//Act
@ -311,11 +311,11 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithQualityNeeded();
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.DVD)))
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.DVD)))
.Returns(false);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.SDTV)))
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.SDTV)))
.Returns(true);
//Act
@ -349,7 +349,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithSuccessfulDownload();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
.Returns(ReportRejectionType.None);
//Act

View File

@ -75,7 +75,6 @@ namespace NzbDrone.Core.Test
(first == second).Should().BeFalse();
}
[Test]
public void not_equal_operand()
{

View File

@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityTypesTest : CoreTest
{
public static object[] FromIntCases =
{
new object[] {1, QualityTypes.SDTV},
new object[] {2, QualityTypes.DVD},
new object[] {4, QualityTypes.HDTV},
new object[] {5, QualityTypes.WEBDL},
new object[] {6, QualityTypes.Bluray720p},
new object[] {7, QualityTypes.Bluray1080p}
};
public static object[] ToIntCases =
{
new object[] {QualityTypes.SDTV, 1},
new object[] {QualityTypes.DVD, 2},
new object[] {QualityTypes.HDTV, 4},
new object[] {QualityTypes.WEBDL, 5},
new object[] {QualityTypes.Bluray720p, 6},
new object[] {QualityTypes.Bluray1080p, 7}
};
[Test, TestCaseSource("FromIntCases")]
public void should_be_able_to_convert_int_to_qualityTypes(int source, QualityTypes expected)
{
var quality = (QualityTypes)source;
quality.Should().Be(expected);
}
[Test, TestCaseSource("ToIntCases")]
public void should_be_able_to_convert_qualityTypes_to_int(QualityTypes source, int expected)
{
var i = (int)source;
i.Should().Be(expected);
}
[Test]
public void Icomparer_greater_test()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
second.Should().BeGreaterThan(first);
}
[Test]
public void Icomparer_lesser()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
first.Should().BeLessThan(second);
}
[Test]
public void equal_operand()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Bluray1080p;
(first == second).Should().BeTrue();
(first >= second).Should().BeTrue();
(first <= second).Should().BeTrue();
}
[Test]
public void equal_operand_false()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Unknown;
(first == second).Should().BeFalse();
}
[Test]
public void not_equal_operand()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Bluray1080p;
(first != second).Should().BeFalse();
}
[Test]
public void not_equal_operand_false()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Unknown;
(first != second).Should().BeTrue();
}
[Test]
public void greater_operand()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
(first < second).Should().BeTrue();
(first <= second).Should().BeTrue();
}
[Test]
public void lesser_operand()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
(second > first).Should().BeTrue();
(second >= first).Should().BeTrue();
}
}
}

View File

@ -1,14 +1,28 @@
using System;
using System.Reflection;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
namespace NzbDrone.Core.Datastore
{
public class CustomeMapper : DefaultMapper
{
public override Func<object, object> GetToDbConverter(Type sourceType)
{
if (sourceType == typeof(QualityTypes))
{
return delegate(object s)
{
var source = (QualityTypes)s;
return source.Id;
};
}
return base.GetToDbConverter(sourceType);
}
public override Func<object, object> GetFromDbConverter(Type destinationType, Type sourceType)
{
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
// If it is NULLABLE, then get the underlying type. eg if "Nullable<int>" then this will return just "int"
@ -31,6 +45,17 @@ namespace NzbDrone.Core.Datastore
};
}
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType == typeof(QualityTypes))
{
return delegate(object s)
{
int value;
Int32.TryParse(s.ToString(), out value);
var quality = (QualityTypes)value;
return quality;
};
}
return base.GetFromDbConverter(destinationType, sourceType);
}

View File

@ -5,7 +5,7 @@ namespace NzbDrone.Core.Model
{
public class QualityModel : IComparable<QualityModel>
{
public QualityTypes QualityType { get; set; }
public QualityTypes Quality { get; set; }
public Boolean Proper { get; set; }
@ -13,19 +13,19 @@ namespace NzbDrone.Core.Model
public QualityModel(QualityTypes quality, Boolean proper)
{
QualityType = quality;
Quality = quality;
Proper = proper;
}
public int CompareTo(QualityModel other)
{
if (other.QualityType > QualityType)
if (other.Quality > Quality)
return -1;
if (other.QualityType < QualityType)
if (other.Quality < Quality)
return 1;
if (other.QualityType == QualityType && other.Proper == Proper)
if (other.Quality == Quality && other.Proper == Proper)
return 0;
if (Proper && !other.Proper)
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Model
public static bool operator <(QualityModel x, QualityModel y)
{
return x.CompareTo(y) < 1;
return x.CompareTo(y) < 0;
}
public static bool operator <=(QualityModel x, QualityModel y)
@ -77,7 +77,7 @@ namespace NzbDrone.Core.Model
public override string ToString()
{
string result = QualityType.ToString();
string result = Quality.ToString();
if (Proper)
{
result += " [proper]";
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Model
{
int hash = 17;
hash = hash * 23 + Proper.GetHashCode();
hash = hash * 23 + QualityType.GetHashCode();
hash = hash * 23 + Quality.GetHashCode();
return hash;
}
}
@ -101,7 +101,7 @@ namespace NzbDrone.Core.Model
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(other.QualityType, QualityType) && other.Proper.Equals(Proper);
return Equals(other.Quality, Quality) && other.Proper.Equals(Proper);
}
public override bool Equals(object obj)

View File

@ -273,7 +273,7 @@
<Compile Include="Model\JobQueueItem.cs" />
<Compile Include="Model\LanguageType.cs" />
<Compile Include="Model\MisnamedEpisodeModel.cs" />
<Compile Include="Model\Quality.cs" />
<Compile Include="Model\QualityModel.cs" />
<Compile Include="Model\Sabnzbd\SabHistoryItem.cs" />
<Compile Include="Model\Sabnzbd\SabHistory.cs" />
<Compile Include="Model\Sabnzbd\SabJsonError.cs" />
@ -330,6 +330,7 @@
<Compile Include="Jobs\UpdateInfoJob.cs" />
<Compile Include="Providers\StatsProvider.cs" />
<Compile Include="Repository\MetadataDefinition.cs" />
<Compile Include="Repository\Quality\QualityTypes.cs" />
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
<Compile Include="Repository\Search\SearchHistory.cs" />
<Compile Include="Model\ReportRejectionType.cs" />
@ -541,7 +542,6 @@
<Compile Include="Repository\Quality\QualityType.cs" />
<Compile Include="Repository\Quality\QualityProfile.cs" />
<Compile Include="Repository\RootDir.cs" />
<Compile Include="Repository\Quality\QualityTypes.cs" />
<Compile Include="Repository\SceneMapping.cs" />
<Compile Include="Repository\Series.cs" />
<Compile Include="CentralDispatch.cs" />

View File

@ -251,12 +251,12 @@ namespace NzbDrone.Core
name = name.Trim();
var normalizedName = NormalizeTitle(name);
var result = new QualityModel { QualityType = QualityTypes.Unknown };
var result = new QualityModel { Quality = QualityTypes.Unknown };
result.Proper = (normalizedName.Contains("proper") || normalizedName.Contains("repack"));
if (normalizedName.Contains("dvd") || normalizedName.Contains("bdrip") || normalizedName.Contains("brrip"))
{
result.QualityType = QualityTypes.DVD;
result.Quality = QualityTypes.DVD;
return result;
}
@ -264,11 +264,11 @@ namespace NzbDrone.Core
{
if (normalizedName.Contains("bluray"))
{
result.QualityType = QualityTypes.DVD;
result.Quality = QualityTypes.DVD;
return result;
}
result.QualityType = QualityTypes.SDTV;
result.Quality = QualityTypes.SDTV;
return result;
}
@ -276,32 +276,32 @@ namespace NzbDrone.Core
{
if (normalizedName.Contains("720p"))
{
result.QualityType = QualityTypes.Bluray720p;
result.Quality = QualityTypes.Bluray720p;
return result;
}
if (normalizedName.Contains("1080p"))
{
result.QualityType = QualityTypes.Bluray1080p;
result.Quality = QualityTypes.Bluray1080p;
return result;
}
result.QualityType = QualityTypes.Bluray720p;
result.Quality = QualityTypes.Bluray720p;
return result;
}
if (normalizedName.Contains("webdl"))
{
result.QualityType = QualityTypes.WEBDL;
result.Quality = QualityTypes.WEBDL;
return result;
}
if (normalizedName.Contains("x264") || normalizedName.Contains("h264") || normalizedName.Contains("720p"))
{
result.QualityType = QualityTypes.HDTV;
result.Quality = QualityTypes.HDTV;
return result;
}
//Based on extension
if (result.QualityType == QualityTypes.Unknown)
if (result.Quality == QualityTypes.Unknown)
{
try
{
@ -322,13 +322,13 @@ namespace NzbDrone.Core
case ".ogm":
case ".strm":
{
result.QualityType = QualityTypes.SDTV;
result.Quality = QualityTypes.SDTV;
break;
}
case ".mkv":
case ".ts":
{
result.QualityType = QualityTypes.HDTV;
result.Quality = QualityTypes.HDTV;
break;
}
}
@ -342,15 +342,15 @@ namespace NzbDrone.Core
if (name.Contains("[HDTV]"))
{
result.QualityType = QualityTypes.HDTV;
result.Quality = QualityTypes.HDTV;
return result;
}
if ((normalizedName.Contains("sdtv") || normalizedName.Contains("pdtv") ||
(result.QualityType == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) &&
(result.Quality == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) &&
!normalizedName.Contains("mpeg"))
{
result.QualityType = QualityTypes.SDTV;
result.Quality = QualityTypes.SDTV;
return result;
}

View File

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Beginning size check for: {0}", subject);
var qualityType = _qualityTypeProvider.Get((int)subject.Quality.QualityType);
var qualityType = _qualityTypeProvider.Get((int)subject.Quality.Quality);
//Need to determine if this is a 30 or 60 minute episode
//Is it a multi-episode release?

View File

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Checking if report meets quality requirements. {0}", subject.Quality);
if (!subject.Series.QualityProfile.Allowed.Contains(subject.Quality.QualityType))
if (!subject.Series.QualityProfile.Allowed.Contains(subject.Quality.Quality))
{
logger.Trace("Quality {0} rejected by Series' quality profile", subject.Quality);
return false;

View File

@ -17,13 +17,13 @@ namespace NzbDrone.Core.Providers.DecisionEngine
return false;
}
if (currentQuality.QualityType == newQuality.QualityType && newQuality.Proper)
if (currentQuality.Quality == newQuality.Quality && newQuality.Proper)
{
logger.Trace("Upgrading existing item to proper.");
return true;
}
if (currentQuality.QualityType >= cutOff)
if (currentQuality.Quality >= cutOff)
{
logger.Trace("Existing item meets cut-off. skipping.");
return false;

View File

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine
foreach (var file in _episodeProvider.GetEpisodesByParseResult(subject).Select(c => c.EpisodeFile).Where(c => c != null))
{
logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper);
if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { QualityType = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff))
if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { Quality = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff))
return false;
}

View File

@ -153,7 +153,7 @@ namespace NzbDrone.Core.Providers
episodeFile.SeriesId = series.SeriesId;
episodeFile.Path = filePath.NormalizePath();
episodeFile.Size = size;
episodeFile.Quality = parseResult.Quality.QualityType;
episodeFile.Quality = parseResult.Quality.Quality;
episodeFile.Proper = parseResult.Quality.Proper;
episodeFile.SeasonNumber = parseResult.SeasonNumber;
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Providers
var parseResult = Parser.ParsePath(episodeFile.Path);
parseResult.Series = series;
parseResult.Quality = new QualityModel{ QualityType = episodeFile.Quality, Proper = episodeFile.Proper };
parseResult.Quality = new QualityModel{ Quality = episodeFile.Quality, Proper = episodeFile.Proper };
var message = _downloadProvider.GetDownloadTitle(parseResult);

View File

@ -61,7 +61,7 @@ namespace NzbDrone.Core.Providers
Date = DateTime.Now,
Indexer = parseResult.Indexer,
IsProper = parseResult.Quality.Proper,
Quality = parseResult.Quality.QualityType,
Quality = parseResult.Quality.Quality,
NzbTitle = parseResult.OriginalString,
EpisodeId = episode.EpisodeId,
SeriesId = episode.SeriesId,
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Providers
if (parseResult.FullSeason)
{
var seasonResult = String.Format("{0} - Season {1} [{2}]", seriesTitle,
parseResult.SeasonNumber, parseResult.Quality.QualityType);
parseResult.SeasonNumber, parseResult.Quality.Quality);
if (parseResult.Quality.Proper)
seasonResult += " [Proper]";
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Providers
if (parseResult.Series.IsDaily)
{
var dailyResult = String.Format("{0} - {1:yyyy-MM-dd} - {2} [{3}]", seriesTitle,
parseResult.AirDate, parseResult.EpisodeTitle, parseResult.Quality.QualityType);
parseResult.AirDate, parseResult.EpisodeTitle, parseResult.Quality.Quality);
if (parseResult.Quality.Proper)
dailyResult += " [Proper]";
@ -137,7 +137,7 @@ namespace NzbDrone.Core.Providers
var epNumberString = String.Join("-", episodeString);
var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, parseResult.EpisodeTitle, parseResult.Quality.QualityType);
var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, parseResult.EpisodeTitle, parseResult.Quality.Quality);
if (parseResult.Quality.Proper)
{

View File

@ -275,7 +275,7 @@ namespace NzbDrone.Core.Providers
ReportTitle = episodeParseResult.OriginalString,
NzbUrl = episodeParseResult.NzbUrl,
Indexer = episodeParseResult.Indexer,
Quality = episodeParseResult.Quality.QualityType,
Quality = episodeParseResult.Quality.Quality,
Proper = episodeParseResult.Quality.Proper,
Size = episodeParseResult.Size,
Age = episodeParseResult.Age,
@ -369,7 +369,7 @@ namespace NzbDrone.Core.Providers
ReportTitle = episodeParseResult.OriginalString,
NzbUrl = episodeParseResult.NzbUrl,
Indexer = episodeParseResult.Indexer,
Quality = episodeParseResult.Quality.QualityType,
Quality = episodeParseResult.Quality.Quality,
Proper = episodeParseResult.Quality.Proper,
Size = episodeParseResult.Size,
Age = episodeParseResult.Age,

View File

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Providers
{
EpisodeId = episodeId,
EpisodeStatus = episodeStatus.ToString(),
Quality = (quality == null ? String.Empty : quality.QualityType.ToString())
Quality = (quality == null ? String.Empty : quality.Quality.ToString())
});
var test = 0;
}

View File

@ -46,7 +46,7 @@ namespace NzbDrone.Core.Repository
}
set
{
Quality = value.QualityType;
Quality = value.Quality;
Proper = value.Proper;
}
}

View File

@ -31,7 +31,7 @@ namespace NzbDrone.Core.Repository.Quality
foreach (var q in Allowed)
{
result += (int)q + "|";
result += q.Id + "|";
}
return result.Trim('|');
}
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Repository.Quality
Allowed = new List<QualityTypes>(qualities.Length);
foreach (var quality in qualities.Where(q => !String.IsNullOrWhiteSpace(q)))
{
Allowed.Add((QualityTypes)Convert.ToInt32(quality));
Allowed.Add(QualityTypes.FindById(Convert.ToInt32(quality)));
}
}
}

View File

@ -1,44 +1,124 @@
using System;
namespace NzbDrone.Core.Repository.Quality
{
// ReSharper disable InconsistentNaming
/// <summary>
/// Represents Video Quality
/// </summary>
public enum QualityTypes
public class QualityTypes : IComparable<QualityTypes>
{
/// <summary>
/// Quality is unknown
/// </summary>
Unknown = 0,
public int Id { get; set; }
public string Name { get; set; }
public int Weight { get; set; }
/// <summary>
/// SD File (Source could be HD)
/// </summary>
SDTV = 1,
public int CompareTo(QualityTypes other)
{
if (other.Weight > Weight)
return -1;
/// <summary>
/// SD File (DVD Source)
/// </summary>
DVD = 2,
if (other.Weight < Weight)
return 1;
/// <summary>
/// HD File (HDTV Source)
/// </summary>
HDTV = 4,
if (other.Weight == Weight)
return 0;
/// <summary>
/// HD File (Online Source)
/// </summary>
WEBDL = 5,
return 0;
}
/// <summary>
/// HD File (720p Blu-ray Source)
/// </summary>
Bluray720p = 6,
public static bool operator !=(QualityTypes x, QualityTypes y)
{
return !(x == y);
}
/// <summary>
/// HD File (1080p Blu-ray Source)
/// </summary>
Bluray1080p = 7,
public static bool operator ==(QualityTypes x, QualityTypes y)
{
var xObj = (Object)x;
var yObj = (object)y;
if (xObj == null || yObj == null)
{
return xObj == yObj;
}
return x.CompareTo(y) == 0;
}
public static bool operator >(QualityTypes x, QualityTypes y)
{
return x.CompareTo(y) > 0;
}
public static bool operator <(QualityTypes x, QualityTypes y)
{
return x.CompareTo(y) < 0;
}
public static bool operator <=(QualityTypes x, QualityTypes y)
{
return x.CompareTo(y) <= 0;
}
public static bool operator >=(QualityTypes x, QualityTypes y)
{
return x.CompareTo(y) >= 0;
}
public override string ToString()
{
return Name;
}
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hash = 17;
hash = hash * 23 + Weight.GetHashCode();
return hash;
}
}
public bool Equals(QualityTypes other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(other.Weight, Weight);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (QualityTypes)) return false;
return Equals((QualityTypes) obj);
}
public static QualityTypes Unknown = new QualityTypes { Id = 0, Name = "Unknown", Weight = 0 };
public static QualityTypes SDTV = new QualityTypes {Id = 1, Name = "SDTV", Weight = 1};
public static QualityTypes DVD = new QualityTypes { Id = 2, Name = "DVD", Weight = 2 };
public static QualityTypes HDTV = new QualityTypes { Id = 4, Name = "HDTV", Weight = 4 };
public static QualityTypes WEBDL = new QualityTypes { Id = 5, Name = "WEBDL", Weight = 5 };
public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 6 };
public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 7 };
public static QualityTypes FindById(int id)
{
if (id == 0) return Unknown;
if (id == 1) return SDTV;
if (id == 2) return DVD;
if (id == 4) return HDTV;
if (id == 5) return WEBDL;
if (id == 6) return Bluray720p;
if (id == 7) return Bluray1080p;
throw new ArgumentException("ID does not match a known quality", "id");
}
public static explicit operator QualityTypes(int id)
{
return FindById(id);
}
public static explicit operator int(QualityTypes quality)
{
return quality.Id;
}
}
}

View File

@ -19,7 +19,7 @@ namespace NzbDrone.Core.Repository.Search
public string NzbInfoUrl { get; set; }
public bool Success { get; set; }
public ReportRejectionType SearchError { get; set; }
public QualityTypes Quality { get; set; }
public Quality.QualityTypes Quality { get; set; }
public bool Proper { get; set; }
public int Age { get; set; }
public LanguageType Language { get; set; }

View File

@ -16,6 +16,7 @@ using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models;
using QualityModel = NzbDrone.Web.Models.QualityModel;
namespace NzbDrone.Web.Controllers
{