1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-17 10:45:49 +02:00

Merge remote-tracking branch 'origin/quality'

This commit is contained in:
Mark McDowall 2012-10-19 08:31:39 -07:00
commit de62dc6f56
76 changed files with 1264 additions and 578 deletions

View File

@ -21,7 +21,7 @@ public void tostring_single_season_episode()
parseResult.EpisodeNumbers = new List<int> { 3 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - S12E03 HDTV");
@ -36,7 +36,7 @@ public void tostring_single_season_episode_proper()
parseResult.EpisodeNumbers = new List<int> { 3 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - S12E03 HDTV [proper]");
@ -51,7 +51,7 @@ public void tostring_multi_season_episode()
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV");
@ -66,7 +66,7 @@ public void tostring_multi_season_episode_proper()
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV [proper]");
@ -81,7 +81,7 @@ public void tostring_full_season()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - Season 12 HDTV");
@ -96,7 +96,7 @@ public void tostring_full_season_proper()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - Season 12 HDTV [proper]");
@ -110,7 +110,7 @@ public void tostring_daily_show()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = new DateTime(2010, 12, 30);
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV");
@ -124,7 +124,7 @@ public void tostring_daily_show_proper()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = new DateTime(2010, 12, 30);
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.Quality = new QualityModel(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV [proper]");

View File

@ -138,10 +138,14 @@ public void newzbin_rss_fetch()
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 @@ public void custome_parser_partial_success(string title, int season, int episode
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

@ -23,5 +23,8 @@
<NamedTestSelector>
<TestName>NzbDrone.Core.Test.Integeration.ServiceIntegerationFixture.should_be_able_to_submit_exceptions</TestName>
</NamedTestSelector>
<NamedTestSelector>
<TestName>NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests.ImportFileFixture.import_unparsable_file_should_skip</TestName>
</NamedTestSelector>
</IgnoredTests>
</ProjectConfiguration>

View File

@ -11,7 +11,7 @@
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 @@ public void unparsable_title_should_report_title()
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,101 @@
// 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.WEBDL720p, 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.WEBDL720p, 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.WEBDL720p, 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.WEBDL720p, false },
new object[] { "Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", QualityTypes.WEBDL720p, false },
new object[] { "Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL720p, false },
new object[] { "Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", QualityTypes.WEBDL720p, false },
new object[] { "CSI NY S09E03 1080p WEB DL DD5 1 H264 NFHD", QualityTypes.WEBDL1080p, false },
new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL1080p, false },
new object[] { "Criminal.Minds.S08E01.1080p.WEB-DL.DD5.1.H264-NFHD", QualityTypes.WEBDL1080p, false },
new object[] { "Its.Always.Sunny.in.Philadelphia.S08E01.1080p.WEB-DL.proper.AAC2.0.H.264", QualityTypes.WEBDL1080p, true },
new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 REPACK NFHD", QualityTypes.WEBDL1080p, true },
};
public static object[] SelfQualityParserCases =
{
new object[] { QualityTypes.SDTV },
new object[] { QualityTypes.DVD },
new object[] { QualityTypes.HDTV },
new object[] { QualityTypes.WEBDL720p },
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

@ -33,7 +33,7 @@ public void Setup()
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new Quality(QualityTypes.SDTV, true),
Quality = new QualityModel(QualityTypes.SDTV, true),
EpisodeNumbers = new List<int> { 3, 4 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date
@ -43,7 +43,7 @@ public void Setup()
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new Quality(QualityTypes.SDTV, true),
Quality = new QualityModel(QualityTypes.SDTV, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date

View File

@ -30,7 +30,7 @@ public void Setup()
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new Quality(QualityTypes.SDTV, true),
Quality = new QualityModel(QualityTypes.SDTV, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date,

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.WEBDL720p },
new object[] { QualityTypes.Bluray720p }
};
[SetUp]
public void Setup()
@ -35,35 +46,28 @@ public void Setup()
parseResult = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new Quality(QualityTypes.DVD, true),
Quality = new QualityModel(QualityTypes.DVD, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
};
}
[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 Quality(current, currentProper), new Quality(newQuality, newProper), cutoff);
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.WEBDL720p, true, QualityTypes.WEBDL720p, 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.WEBDL720p, false, QualityTypes.HDTV, true, QualityTypes.Bluray720p, false },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.HDTV, true, QualityTypes.WEBDL720p, false },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.WEBDL720p, false, QualityTypes.WEBDL720p, 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

@ -38,7 +38,7 @@ public void Setup()
parseResultMulti = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new Quality(QualityTypes.DVD, true),
Quality = new QualityModel(QualityTypes.DVD, true),
EpisodeNumbers = new List<int> { 3, 4 },
SeasonNumber = 12,
};
@ -46,7 +46,7 @@ public void Setup()
parseResultSingle = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new Quality(QualityTypes.DVD, true),
Quality = new QualityModel(QualityTypes.DVD, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
};

View File

@ -22,8 +22,8 @@ public class UpgradeHistorySpecificationFixtrue : CoreTest
private EpisodeParseResult parseResultMulti;
private EpisodeParseResult parseResultSingle;
private Quality firstQuality;
private Quality secondQuality;
private QualityModel firstQuality;
private QualityModel secondQuality;
[SetUp]
public void Setup()
@ -38,7 +38,7 @@ public void Setup()
parseResultMulti = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new Quality(QualityTypes.DVD, true),
Quality = new QualityModel(QualityTypes.DVD, true),
EpisodeNumbers = new List<int> { 3, 4 },
SeasonNumber = 12,
};
@ -46,13 +46,13 @@ public void Setup()
parseResultSingle = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new Quality(QualityTypes.DVD, true),
Quality = new QualityModel(QualityTypes.DVD, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
};
firstQuality = new Quality(QualityTypes.Bluray1080p, true);
secondQuality = new Quality(QualityTypes.Bluray1080p, true);
firstQuality = new QualityModel(QualityTypes.Bluray1080p, true);
secondQuality = new QualityModel(QualityTypes.Bluray1080p, true);
var singleEpisodeList = new List<Episode> { new Episode { SeasonNumber = 12, EpisodeNumber = 3 } };
var doubleEpisodeList = new List<Episode> {
@ -66,17 +66,17 @@ public void Setup()
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 3)).Returns(firstQuality);
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 4)).Returns(secondQuality);
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 5)).Returns<Quality>(null);
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 5)).Returns<QualityModel>(null);
}
private void WithFirstReportUpgradable()
{
firstQuality.QualityType = QualityTypes.SDTV;
firstQuality.Quality = QualityTypes.SDTV;
}
private void WithSecondReportUpgradable()
{
secondQuality.QualityType = QualityTypes.SDTV;
secondQuality.Quality = QualityTypes.SDTV;
}

View File

@ -19,7 +19,7 @@ public class UpgradePossibleSpecificationFixture : CoreTest
{
private void WithWebdlCutoff()
{
var profile = new QualityProfile { Cutoff = QualityTypes.WEBDL };
var profile = new QualityProfile { Cutoff = QualityTypes.WEBDL720p };
Mocker.GetMock<QualityProvider>().Setup(s => s.Get(It.IsAny<int>())).Returns(profile);
}
@ -77,7 +77,7 @@ public void IsUpgradePossible_should_return_false_if_current_episode_is_equal_to
{
WithWebdlCutoff();
_episodeFile.Quality = QualityTypes.WEBDL;
_episodeFile.Quality = QualityTypes.WEBDL720p;
//Act
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(_episode);

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 @@ public void import_new_file_should_succeed()
}
[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 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
.Build())
.Build();
//Mocks
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();

View File

@ -91,7 +91,7 @@ public void should_use_EpisodeFiles_quality()
var file = Builder<EpisodeFile>.CreateNew()
.With(f => f.SeriesId = fakeSeries.SeriesId)
.With(f => f.Path = currentFilename)
.With(f => f.Quality = QualityTypes.WEBDL)
.With(f => f.Quality = QualityTypes.WEBDL720p)
.With(f => f.Proper = false)
.Build();
@ -112,7 +112,7 @@ public void should_use_EpisodeFiles_quality()
.Returns(fi);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new Quality{ QualityType = QualityTypes.WEBDL, Proper = false })))
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel{ Quality = QualityTypes.WEBDL720p, Proper = false })))
.Returns(message);
Mocker.GetMock<ExternalNotificationProvider>()

View File

@ -128,7 +128,7 @@ public void is_in_queue_should_find_if_exact_episode_is_in_queue()
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 5 },
SeasonNumber = 1,
Quality = new Quality { 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 @@ public void is_in_queue_should_find_if_exact_daily_episode_is_in_queue()
var parseResult = new EpisodeParseResult
{
Quality = new Quality { 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 @@ public void is_in_queue_should_find_if_exact_full_season_release_is_in_queue()
var parseResult = new EpisodeParseResult
{
Quality = new Quality { 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 @@ public void is_in_queue_should_find_if_exact_full_season_release_is_in_queue()
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 @@ public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] e
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new Quality { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -200,12 +205,17 @@ public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] e
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.WEBDL720p }, 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 @@ public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new Quality { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -224,10 +234,15 @@ public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season
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 @@ public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] ep
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new Quality { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -246,10 +261,15 @@ public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] ep
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 @@ public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, s
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new Quality { QualityType = qualityType, Proper = proper },
Quality = new QualityModel { Quality = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
@ -278,7 +298,7 @@ public void IsInQueue_should_return_false_if_queue_is_empty()
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 1 },
SeasonNumber = 2,
Quality = new Quality { 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)
{
@ -40,7 +49,7 @@ private EpisodeParseResult SetupParseResult()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(episodes);
return Builder<EpisodeParseResult>.CreateNew()
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, false))
.With(c => c.Series = Builder<Series>.CreateNew().Build())
.With(c => c.EpisodeNumbers = new List<int>{2})
.Build();
@ -68,7 +77,6 @@ private void WithFailedAdd()
.Returns(false);
}
[Test]
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
{
@ -162,8 +170,6 @@ public void Download_report_should_not_add_to_history_mark_as_grabbed_if_add_fai
.Verify(c => c.OnGrab(It.IsAny<String>()), Times.Never());
}
[Test]
public void should_return_sab_as_active_client()
{
@ -178,14 +184,8 @@ public void should_return_blackhole_as_active_client()
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")
@ -195,13 +195,13 @@ public string create_proper_sab_titles(int seasons, int[] episodes, string title
{
AirDate = DateTime.Now,
EpisodeNumbers = episodes.ToList(),
Quality = new Quality(quality, proper),
Quality = new QualityModel(quality, proper),
SeasonNumber = seasons,
Series = series,
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]")]
@ -215,7 +215,7 @@ public string create_proper_sab_season_title(bool proper)
var parsResult = new EpisodeParseResult()
{
AirDate = DateTime.Now,
Quality = new Quality(QualityTypes.Bluray720p, proper),
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
SeasonNumber = 1,
Series = series,
EpisodeTitle = "My Episode Title",
@ -237,7 +237,7 @@ public string create_proper_sab_daily_titles(bool proper)
var parsResult = new EpisodeParseResult
{
AirDate = new DateTime(2011, 12, 1),
Quality = new Quality(QualityTypes.Bluray720p, proper),
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
Series = series,
EpisodeTitle = "My Episode Title",
};

View File

@ -88,7 +88,7 @@ public void GetEpisode_with_EpisodeFile()
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 @@ public void GetEpisode_by_Season_Episode_with_EpisodeFile()
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 @@ public void GetEpisode_by_AirDate_with_EpisodeFile()
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 @@ public void EpisodesWithFiles_success()
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 @@ public void AllItems()
{
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 @@ public void AllItemsWithRelationships()
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 @@ public void PurgeItem()
{
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 @@ public void Trim_Items()
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 @@ public void GetBestQualityInHistory_single_result()
//Assert
result.Should().NotBeNull();
result.QualityType.Should().Be(QualityTypes.Bluray720p);
result.Quality.Should().Be(QualityTypes.Bluray720p);
result.Proper.Should().BeTrue();
}
@ -184,7 +201,7 @@ public void GetBestQualityInHistory_should_return_highest_result()
//Assert
result.Should().NotBeNull();
result.QualityType.Should().Be(QualityTypes.Bluray720p);
result.Quality.Should().Be(QualityTypes.Bluray720p);
result.Proper.Should().BeTrue();
}
@ -195,7 +212,7 @@ public void add_item()
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.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 @@ public class MediaFileProviderTest : CoreTest
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 @@ public void get_season_files()
{
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 @@ public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int sea
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 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database()
//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.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 @@ public void CleanUpDatabse_should_not_change_episodes_with_no_file_id()
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

@ -29,26 +29,24 @@ public void SetupDefault_should_add_six_profiles()
//Assert
var types = Mocker.Resolve<QualityTypeProvider>().All();
types.Should().HaveCount(6);
types.Should().HaveCount(7);
types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1);
types.Should().Contain(e => e.Name == "DVD" && e.QualityTypeId == 2);
types.Should().Contain(e => e.Name == "HDTV" && e.QualityTypeId == 4);
types.Should().Contain(e => e.Name == "WEBDL" && e.QualityTypeId == 5);
types.Should().Contain(e => e.Name == "WEBDL720p" && e.QualityTypeId == 5);
types.Should().Contain(e => e.Name == "WEBDL1080p" && e.QualityTypeId == 3);
types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityTypeId == 6);
types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityTypeId == 7);
}
[Test]
public void SetupDefault_already_exists()
public void SetupDefault_already_exists_should_insert_missing()
{
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
var fakeQualityType = Builder<QualityType>.CreateNew()
.Build();
db.Insert(fakeQualityType);
db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
//Act
Mocker.Resolve<QualityTypeProvider>().SetupDefault();
@ -56,7 +54,7 @@ public void SetupDefault_already_exists()
//Assert
var types = Mocker.Resolve<QualityTypeProvider>().All();
types.Should().HaveCount(1);
types.Should().HaveCount(7);
}
[Test]

View File

@ -37,6 +37,8 @@ public void Setup()
.Build();
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.Build().ToList();
_searchHistory = Builder<SearchHistory>.CreateNew()
@ -77,6 +79,7 @@ private void WithExpiredHistory()
{
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(i => i.Id == searchHistory.Id)
.Build();
@ -97,6 +100,7 @@ private void WithValidHistory()
{
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(i => i.Id == searchHistory.Id)
.Build();

View File

@ -93,16 +93,16 @@ public void processSearchResults_higher_quality_should_be_called_first()
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(c => c.AirDate = DateTime.Today)
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.Random(1)
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.Build();
WithMatchingSeries();
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
@ -123,7 +123,7 @@ public void processSearchResults_when_quality_is_not_needed_should_check_the_res
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(c => c.AirDate = DateTime.Today)
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.Build();
WithMatchingSeries();
@ -147,7 +147,7 @@ public void processSearchResults_should_skip_if_series_is_null()
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(e => e.AirDate = DateTime.Today)
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithNullSeries();
@ -168,7 +168,7 @@ public void processSearchResults_should_skip_if_series_is_mismatched()
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(e => e.AirDate = DateTime.Today)
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithMisMatchedSeries();
@ -189,7 +189,7 @@ public void processSearchResults_should_return_after_successful_download()
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(2)
.All()
.With(e => e.AirDate = DateTime.Today)
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.Build();
WithMatchingSeries();
@ -212,20 +212,20 @@ public void processSearchResults_should_try_next_if_download_fails()
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(2)
.All()
.With(e => e.AirDate = DateTime.Today)
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.TheLast(1)
.With(c => c.Quality = new Quality(QualityTypes.SDTV, true))
.With(c => c.Quality = new QualityModel(QualityTypes.SDTV, true))
.Build();
WithMatchingSeries();
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
@ -244,7 +244,7 @@ public void processSearchResults_should_skip_if_parseResult_does_not_have_airdat
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(e => e.AirDate = null)
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithMatchingSeries();
@ -265,7 +265,7 @@ public void processSearchResults_should_skip_if_parseResult_airdate_does_not_mat
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(e => e.AirDate = DateTime.Today.AddDays(10))
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithMatchingSeries();

View File

@ -91,10 +91,10 @@ public void processSearchResults_higher_quality_should_be_called_first()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Age = 10)
.Random(1)
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 100)
.Build();
@ -102,7 +102,7 @@ public void processSearchResults_higher_quality_should_be_called_first()
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
@ -125,7 +125,7 @@ public void processSearchResults_newer_report_should_be_called_first()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 300)
.Build();
@ -157,7 +157,7 @@ public void processSearchResults_when_quality_is_not_needed_should_check_the_res
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.Build();
WithMatchingSeries();
@ -183,7 +183,7 @@ public void processSearchResults_should_skip_if_series_is_null()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithNullSeries();
@ -206,7 +206,7 @@ public void processSearchResults_should_skip_if_series_is_mismatched()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithMisMatchedSeries();
@ -229,7 +229,7 @@ public void processSearchResults_should_skip_if_season_doesnt_match()
.All()
.With(e => e.SeasonNumber = 2)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithMatchingSeries();
@ -252,7 +252,7 @@ public void processSearchResults_should_skip_if_episodeNumber_doesnt_match()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 2 })
.With(e => e.Quality = new Quality(QualityTypes.HDTV, false))
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV, false))
.Build();
WithMatchingSeries();
@ -275,7 +275,7 @@ public void processSearchResults_should_skip_if_any_episodeNumber_was_already_ad
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 5 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.TheLast(1)
.With(e => e.EpisodeNumbers = new List<int> { 1, 2, 3, 4, 5 })
.Build();
@ -302,20 +302,20 @@ public void processSearchResults_should_try_next_if_download_fails()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.TheLast(1)
.With(c => c.Quality = new Quality(QualityTypes.SDTV, true))
.With(c => c.Quality = new QualityModel(QualityTypes.SDTV, true))
.Build();
WithMatchingSeries();
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
@ -336,10 +336,10 @@ public void processSearchResults_Successes_should_not_be_null_or_empty()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Age = 10)
.Random(1)
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 100)
.Build();
@ -349,7 +349,7 @@ public void processSearchResults_Successes_should_not_be_null_or_empty()
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

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
@ -16,6 +17,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestFixture]
public class SeriesProviderTest : CoreTest
{
private IList<QualityProfile> _qualityProfiles;
[SetUp]
public void Setup()
{
_qualityProfiles = Builder<QualityProfile>
.CreateListOfSize(2)
.All()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
}
[TestCase(true)]
[TestCase(false)]
public void Add_new_series(bool useSeasonFolder)
@ -25,7 +39,12 @@ public void Add_new_series(bool useSeasonFolder)
Mocker.GetMock<ConfigProvider>()
.Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder);
var fakeProfiles = Builder<QualityProfile>.CreateListOfSize(2).Build();
var fakeProfiles = Builder<QualityProfile>
.CreateListOfSize(2)
.All()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
Db.InsertMany(fakeProfiles);
@ -96,7 +115,12 @@ public void Get_series_by_id()
.With(c => c.EpisodeFileCount = 0)
.With(c => c.SeasonCount = 0)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>
.CreateNew()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
Db.Insert(fakeSeries);
Db.Insert(fakeQuality);
@ -121,7 +145,12 @@ public void Find_series_by_cleanName_mapped()
.With(c => c.QualityProfileId = 1)
.With(c => c.CleanTitle = "laworder")
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>
.CreateNew()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
var id = Db.Insert(fakeSeries);
Db.Insert(fakeQuality);
@ -168,6 +197,8 @@ public void find_series_match(string title, string searchTitle)
var fakeQuality = Builder<QualityProfile>.CreateNew()
.With(c => c.QualityProfileId = fakeSeries.QualityProfileId)
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
Db.Insert(fakeSeries);
@ -197,7 +228,11 @@ public void is_monitored()
.With(c => c.SeriesId = 11)
.Build());
Db.InsertMany(Builder<QualityProfile>.CreateListOfSize(3).Build());
Db.InsertMany(Builder<QualityProfile>.CreateListOfSize(3)
.All()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build());
//Act, Assert
var provider = Mocker.Resolve<SeriesProvider>();
@ -211,7 +246,7 @@ public void Get_Series_With_Count()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All().With(e => e.SeriesId = fakeSeries.SeriesId)
@ -242,7 +277,7 @@ public void Get_Series_With_Count_AllIgnored()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10).All().With(e => e.SeriesId = fakeSeries.SeriesId).With(e => e.Ignored = true).Random(5).With(e => e.EpisodeFileId = 0).Build();
@ -265,7 +300,7 @@ public void Get_Series_With_Count_AllDownloaded()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All()
@ -293,7 +328,7 @@ public void Get_Series_With_Count_Half_Ignored()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All()
@ -324,7 +359,7 @@ public void Get_Series_should_not_return_series_that_do_not_have_info_synced_yet
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(5)
.All()
@ -360,7 +395,7 @@ public void Get_Single_Series()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
.With(e => e.SeriesId = 1)
@ -391,7 +426,7 @@ public void SeriesPathExists_exact_match()
.TheFirst(1)
.With(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality);
@ -420,7 +455,7 @@ public void SeriesPathExists_match()
.TheFirst(1)
.With(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality);
@ -449,7 +484,7 @@ public void SeriesPathExists_match_alt()
.TheFirst(1)
.With(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality);
@ -478,7 +513,7 @@ public void SeriesPathExists_match_false()
.TheFirst(1)
.With(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality);
@ -499,7 +534,7 @@ public void Get_Series_NextAiring_Today()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -528,7 +563,7 @@ public void Get_Series_NextAiring_Tomorrow_Last_Aired_Yesterday()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -557,7 +592,7 @@ public void Get_Series_NextAiring_Unknown()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -584,7 +619,7 @@ public void Get_Series_NextAiring_1_month()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -613,7 +648,7 @@ public void Get_Series_NextAiring_skip_ignored()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -643,7 +678,7 @@ public void SearchForSeries_should_return_results_that_start_with_query()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -664,7 +699,7 @@ public void SearchForSeries_should_return_results_that_contain_the_query()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -685,7 +720,7 @@ public void SearchForSeries_should_return_results_that_end_with_the_query()
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -706,7 +741,7 @@ public void SearchForSeries_should_not_return_results_that_do_not_contain_the_qu
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -727,7 +762,7 @@ public void SearchForSeries_should_return_results_when_query_has_special_charact
{
WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -753,7 +788,7 @@ public void UpdateFromMassEdit_should_only_update_certain_values()
var newMonitored = false;
var newSeasonFolder = false;
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(1)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -790,7 +825,7 @@ public void UpdateFromMassEdit_should_only_update_changed_values()
var monitored = true;
var seasonFolder = true;
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(2)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)

View File

@ -155,7 +155,7 @@ public void SetupInitial_should_skip_if_any_profile_exists()
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
var fakeProfile = Builder<QualityProfile>.CreateNew().Build();
var fakeProfile = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
//Act
Mocker.Resolve<QualityProvider>().Add(fakeProfile);

View File

@ -13,8 +13,8 @@ public class QualityTest : CoreTest
[Test]
public void Icomparer_greater_test()
{
var first = new Quality(QualityTypes.DVD, true);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
second.Should().BeGreaterThan(first);
}
@ -22,8 +22,8 @@ public void Icomparer_greater_test()
[Test]
public void Icomparer_greater_proper()
{
var first = new Quality(QualityTypes.Bluray1080p, false);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.Bluray1080p, false);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
second.Should().BeGreaterThan(first);
}
@ -31,8 +31,8 @@ public void Icomparer_greater_proper()
[Test]
public void Icomparer_lesser()
{
var first = new Quality(QualityTypes.DVD, true);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
first.Should().BeLessThan(second);
}
@ -40,8 +40,8 @@ public void Icomparer_lesser()
[Test]
public void Icomparer_lesser_proper()
{
var first = new Quality(QualityTypes.DVD, false);
var second = new Quality(QualityTypes.DVD, true);
var first = new QualityModel(QualityTypes.DVD, false);
var second = new QualityModel(QualityTypes.DVD, true);
first.Should().BeLessThan(second);
}
@ -49,8 +49,8 @@ public void Icomparer_lesser_proper()
[Test]
public void equal_operand()
{
var first = new Quality(QualityTypes.Bluray1080p, true);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
(first == second).Should().BeTrue();
(first >= second).Should().BeTrue();
@ -60,8 +60,8 @@ public void equal_operand()
[Test]
public void equal_operand_false()
{
var first = new Quality(QualityTypes.Bluray1080p, true);
var second = new Quality(QualityTypes.Unknown, true);
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Unknown, true);
(first == second).Should().BeFalse();
}
@ -69,18 +69,17 @@ public void equal_operand_false()
[Test]
public void equal_operand_false_proper()
{
var first = new Quality(QualityTypes.Bluray1080p, true);
var second = new Quality(QualityTypes.Bluray1080p, false);
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, false);
(first == second).Should().BeFalse();
}
[Test]
public void not_equal_operand()
{
var first = new Quality(QualityTypes.Bluray1080p, true);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
(first != second).Should().BeFalse();
}
@ -88,8 +87,8 @@ public void not_equal_operand()
[Test]
public void not_equal_operand_false()
{
var first = new Quality(QualityTypes.Bluray1080p, true);
var second = new Quality(QualityTypes.Unknown, true);
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Unknown, true);
(first != second).Should().BeTrue();
}
@ -97,8 +96,8 @@ public void not_equal_operand_false()
[Test]
public void not_equal_operand_false_proper()
{
var first = new Quality(QualityTypes.Bluray1080p, true);
var second = new Quality(QualityTypes.Bluray1080p, false);
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, false);
(first != second).Should().BeTrue();
}
@ -106,8 +105,8 @@ public void not_equal_operand_false_proper()
[Test]
public void greater_operand()
{
var first = new Quality(QualityTypes.DVD, true);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
(first < second).Should().BeTrue();
(first <= second).Should().BeTrue();
@ -116,8 +115,8 @@ public void greater_operand()
[Test]
public void lesser_operand()
{
var first = new Quality(QualityTypes.DVD, true);
var second = new Quality(QualityTypes.Bluray1080p, true);
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
(second > first).Should().BeTrue();
(second >= first).Should().BeTrue();

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.WEBDL720p},
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.WEBDL720p, 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 @@ public override Func<object, object> GetFromDbConverter(Type destinationType, Ty
};
}
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

@ -24,7 +24,7 @@ public string CleanTitle
public DateTime? AirDate { get; set; }
public Quality Quality { get; set; }
public QualityModel Quality { get; set; }
public LanguageType Language { get; set; }

View File

@ -3,29 +3,29 @@
namespace NzbDrone.Core.Model
{
public class Quality : IComparable<Quality>
public class QualityModel : IComparable<QualityModel>
{
public QualityTypes QualityType { get; set; }
public QualityTypes Quality { get; set; }
public Boolean Proper { get; set; }
public Quality() { }
public QualityModel() { }
public Quality(QualityTypes quality, Boolean proper)
public QualityModel(QualityTypes quality, Boolean proper)
{
QualityType = quality;
Quality = quality;
Proper = proper;
}
public int CompareTo(Quality other)
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)
@ -37,12 +37,12 @@ public int CompareTo(Quality other)
return 0;
}
public static bool operator !=(Quality x, Quality y)
public static bool operator !=(QualityModel x, QualityModel y)
{
return !(x == y);
}
public static bool operator ==(Quality x, Quality y)
public static bool operator ==(QualityModel x, QualityModel y)
{
var xObj = (Object)x;
var yObj = (object)y;
@ -55,29 +55,29 @@ public int CompareTo(Quality other)
return x.CompareTo(y) == 0;
}
public static bool operator >(Quality x, Quality y)
public static bool operator >(QualityModel x, QualityModel y)
{
return x.CompareTo(y) > 0;
}
public static bool operator <(Quality x, Quality y)
public static bool operator <(QualityModel x, QualityModel y)
{
return x.CompareTo(y) < 1;
return x.CompareTo(y) < 0;
}
public static bool operator <=(Quality x, Quality y)
public static bool operator <=(QualityModel x, QualityModel y)
{
return x.CompareTo(y) <= 0;
}
public static bool operator >=(Quality x, Quality y)
public static bool operator >=(QualityModel x, QualityModel y)
{
return x.CompareTo(y) >= 0;
}
public override string ToString()
{
string result = QualityType.ToString();
string result = Quality.ToString();
if (Proper)
{
result += " [proper]";
@ -92,24 +92,24 @@ public override int GetHashCode()
{
int hash = 17;
hash = hash * 23 + Proper.GetHashCode();
hash = hash * 23 + QualityType.GetHashCode();
hash = hash * 23 + Quality.GetHashCode();
return hash;
}
}
public bool Equals(Quality other)
public bool Equals(QualityModel other)
{
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)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (Quality)) return false;
return Equals((Quality) obj);
if (obj.GetType() != typeof (QualityModel)) return false;
return Equals((QualityModel) obj);
}
}
}

View File

@ -6,7 +6,7 @@ public class SeasonParseResult
internal int SeasonNumber { get; set; }
internal int Year { get; set; }
public Quality Quality { get; set; }
public QualityModel Quality { get; set; }
public override string ToString()
{

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

@ -253,18 +253,18 @@ public static string ParseSeriesName(string title)
return NormalizeTitle(title);
}
internal static Quality ParseQuality(string name)
internal static QualityModel ParseQuality(string name)
{
Logger.Trace("Trying to parse quality for {0}", name);
name = name.Trim();
var normalizedName = NormalizeTitle(name);
var result = new Quality { 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;
}
@ -272,11 +272,11 @@ internal static Quality ParseQuality(string name)
{
if (normalizedName.Contains("bluray"))
{
result.QualityType = QualityTypes.DVD;
result.Quality = QualityTypes.DVD;
return result;
}
result.QualityType = QualityTypes.SDTV;
result.Quality = QualityTypes.SDTV;
return result;
}
@ -284,32 +284,37 @@ internal static Quality ParseQuality(string name)
{
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;
if (normalizedName.Contains("1080p"))
{
result.Quality = QualityTypes.WEBDL1080p;
return result;
}
result.Quality = QualityTypes.WEBDL720p;
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
{
@ -330,13 +335,13 @@ internal static Quality ParseQuality(string name)
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;
}
}
@ -350,15 +355,15 @@ internal static Quality ParseQuality(string name)
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 @@ public AcceptableSizeSpecification()
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 @@ public class QualityAllowedByProfileSpecification
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

@ -9,7 +9,7 @@ public class QualityUpgradeSpecification
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public virtual bool IsSatisfiedBy(Quality currentQuality, Quality newQuality, QualityTypes cutOff)
public virtual bool IsSatisfiedBy(QualityModel currentQuality, QualityModel newQuality, QualityTypes cutOff)
{
if (currentQuality >= newQuality)
{
@ -17,13 +17,13 @@ public virtual bool IsSatisfiedBy(Quality currentQuality, Quality newQuality, Qu
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 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
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 Quality { 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 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
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 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
var parseResult = Parser.ParsePath(episodeFile.Path);
parseResult.Series = series;
parseResult.Quality = new Quality{ 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 @@ public virtual bool DownloadReport(EpisodeParseResult parseResult)
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,
@ -104,7 +104,7 @@ public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
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]";
@ -115,7 +115,7 @@ public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
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]";
@ -134,7 +134,7 @@ public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
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

@ -60,7 +60,7 @@ public virtual void Add(History item)
logger.Debug("Item added to history: {0}", item.NzbTitle);
}
public virtual Quality GetBestQualityInHistory(int seriesId, int seasonNumber, int episodeNumber)
public virtual QualityModel GetBestQualityInHistory(int seriesId, int seasonNumber, int episodeNumber)
{
var quality = _database.SingleOrDefault<dynamic>(@"SELECT TOP 1 History.Quality , History.IsProper FROM History
INNER JOIN Episodes ON History.EpisodeId = Episodes.EpisodeId
@ -72,7 +72,7 @@ public virtual Quality GetBestQualityInHistory(int seriesId, int seasonNumber, i
if (quality == null) return null;
return new Quality((QualityTypes)quality.Quality, quality.IsProper);
return new QualityModel((QualityTypes)quality.Quality, quality.IsProper);
}
public virtual void Delete(int historyId)

View File

@ -68,7 +68,7 @@ public virtual void SetupDefaultProfiles()
var hd = new QualityProfile
{
Name = "HD",
Allowed = new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720p },
Allowed = new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL720p, QualityTypes.Bluray720p },
Cutoff = QualityTypes.HDTV
};

View File

@ -54,8 +54,7 @@ public virtual List<QualityType> GetList(List<int> qualityTypeIds)
public virtual void SetupDefault()
{
if (All().Count != 0)
return;
var inDb = All();
Logger.Debug("Setting up default quality types");
@ -63,11 +62,18 @@ public virtual void SetupDefault()
qualityTypes.Add(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 2, Name = "DVD", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 4, Name = "HDTV", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 5, Name = "WEBDL", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 5, Name = "WEBDL720p", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 3, Name = "WEBDL1080p", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 6, Name = "Bluray720p", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 7, Name = "Bluray1080p", MinSize = 0, MaxSize = 100 });
_database.InsertMany(qualityTypes);
foreach(var qualityType in qualityTypes)
{
var db = inDb.SingleOrDefault(s => s.QualityTypeId == qualityType.QualityTypeId);
if (db == null)
_database.Insert(qualityType);
}
}
}
}

View File

@ -275,7 +275,7 @@ public List<SearchHistoryItem> ProcessSearchResults(ProgressNotification notific
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 @@ public List<SearchHistoryItem> ProcessSearchResults(ProgressNotification notific
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

@ -16,7 +16,7 @@ public class SignalRProvider : Hub
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, Quality quality)
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, QualityModel quality)
{
try
{
@ -26,7 +26,7 @@ public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episode
{
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

@ -38,15 +38,15 @@ public EpisodeFile(EpisodeFile source)
public string ReleaseGroup { get; set; }
[Ignore]
public Model.Quality QualityWrapper
public Model.QualityModel QualityWrapper
{
get
{
return new Model.Quality(Quality, Proper);
return new Model.QualityModel(Quality, Proper);
}
set
{
Quality = value.QualityType;
Quality = value.Quality;
Proper = value.Proper;
}
}

View File

@ -31,7 +31,7 @@ public string SonicAllowed
foreach (var q in Allowed)
{
result += (int)q + "|";
result += q.Id + "|";
}
return result.Trim('|');
}
@ -41,7 +41,7 @@ private set
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,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
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 WEBDL720p = new QualityTypes { Id = 5, Name = "WEBDL-720p", Weight = 5 };
public static QualityTypes WEBDL1080p = new QualityTypes { Id = 3, Name = "WEBDL-1080p", Weight = 7 };
public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 6 };
public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 8 };
public static List<QualityTypes> All()
{
return new List<QualityTypes>
{
Unknown,
SDTV,
DVD,
HDTV,
WEBDL720p,
WEBDL1080p,
Bluray720p,
Bluray1080p
};
}
public static QualityTypes FindById(int id)
{
var quality = All().SingleOrDefault(q => q.Id == id);
if (quality == null)
throw new ArgumentException("ID does not match a known quality", "id");
return quality;
}
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 @@ public class SearchHistoryItem
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

@ -1,6 +1,11 @@
#top
{
overflow: auto;
margin: 20px;
overflow: hidden;
}
#top .settingsForm {
float: left;
}
#profileContainer
@ -59,7 +64,7 @@
.profileSection
{
float: left;
width: 270px;
width: 265px;
margin: 2px;
border:solid 1px #CCCCCD;
display: inline-block;
@ -74,7 +79,7 @@
margin-right: 20px;
font-weight: bold;
display: inline-block;
width: 50px;
width: 40px;
}
.profileOptions input, .profileOptions select
@ -142,7 +147,6 @@
width: 600px;
}
.slider-container
{
margin-bottom: 10px;
#QualityForm .ui-accordion .ui-accordion-content {
padding: 1em 2em;
}

View File

@ -115,5 +115,40 @@
}
.settingsForm .validation-error {
background: url("../Content/jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404;
}
background: url("../Content/jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404;
}
/* Navigation */
.settings-navigation {
line-height: normal;
list-style: none outside none;
margin-left: 5px;
margin-bottom: 30px;
padding: 5px 0px 20px 0px;
}
.settings-navigation li {
display: block;
float: left;
padding: 5px;
}
.settings-navigation li.current_action a {
background-color: #065EFE;
}
.settings-navigation a {
background-color: #191919;
color: white;
display: block;
float: left;
font-family: "Segoe UI","Open Sans","Segoe UI Light",sans-serif;
font-size: 16px;
font-weight: normal;
height: 26px;
padding: 2px 10px;
text-align: center;
text-decoration: none;
vertical-align: middle;
}

View File

@ -139,8 +139,7 @@ public ActionResult Details(int seriesId)
}).ToList();
model.Seasons = seasons;
var qualities = (from QualityTypes q in Enum.GetValues(typeof(QualityTypes))
select new { Id = (int)q, Name = q.ToString() }).ToList();
var qualities = QualityTypes.All().ToList();
model.QualitySelectList = new SelectList(qualities.Where(q => q.Id > 0), "Id", "Name");

View File

@ -16,13 +16,13 @@
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models;
using QualityModel = NzbDrone.Web.Models.QualityModel;
namespace NzbDrone.Web.Controllers
{
[HandleError]
public class SettingsController : Controller
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IndexerProvider _indexerProvider;
private readonly QualityProvider _qualityProvider;
@ -35,6 +35,8 @@ public class SettingsController : Controller
private readonly MetadataProvider _metadataProvider;
private readonly JobProvider _jobProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, AutoConfigureProvider autoConfigureProvider,
SeriesProvider seriesProvider, ExternalNotificationProvider externalNotificationProvider,
@ -58,7 +60,33 @@ public SettingsController(ConfigProvider configProvider, IndexerProvider indexer
public ActionResult Index()
{
return View();
return RedirectToAction("Naming", "Settings");
}
public ActionResult Naming()
{
var model = new EpisodeNamingModel();
model.SeriesName = _configProvider.SortingIncludeSeriesName;
model.EpisodeName = _configProvider.SortingIncludeEpisodeTitle;
model.ReplaceSpaces = _configProvider.SortingReplaceSpaces;
model.AppendQuality = _configProvider.SortingAppendQuality;
model.SeasonFolders = _configProvider.UseSeasonFolder;
model.SeasonFolderFormat = _configProvider.SortingSeasonFolderFormat;
model.SeparatorStyle = _configProvider.SortingSeparatorStyle;
model.NumberStyle = _configProvider.SortingNumberStyle;
model.MultiEpisodeStyle = _configProvider.SortingMultiEpisodeStyle;
model.SceneName = _configProvider.SortingUseSceneName;
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name");
//Metadata
model.MetadataXbmcEnabled = _metadataProvider.GetSettings(typeof(Core.Providers.Metadata.Xbmc)).Enable;
model.MetadataUseBanners = _configProvider.MetadataUseBanners;
return View(model);
}
public ActionResult Indexers()
@ -126,7 +154,7 @@ public ActionResult DownloadClient()
public ActionResult Quality()
{
var profiles = _qualityProvider.All().ToList();
var profiles = _qualityProvider.All();
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile);
var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name");
@ -139,7 +167,8 @@ public ActionResult Quality()
SdtvMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 1).MaxSize,
DvdMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 2).MaxSize,
HdtvMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 4).MaxSize,
WebdlMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 5).MaxSize,
Webdl720pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 5).MaxSize,
Webdl1080pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 3).MaxSize,
Bluray720pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 6).MaxSize,
Bluray1080pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 7).MaxSize
};
@ -199,32 +228,6 @@ public ActionResult Notifications()
return View(model);
}
public ActionResult Naming()
{
var model = new EpisodeNamingModel();
model.SeriesName = _configProvider.SortingIncludeSeriesName;
model.EpisodeName = _configProvider.SortingIncludeEpisodeTitle;
model.ReplaceSpaces = _configProvider.SortingReplaceSpaces;
model.AppendQuality = _configProvider.SortingAppendQuality;
model.SeasonFolders = _configProvider.UseSeasonFolder;
model.SeasonFolderFormat = _configProvider.SortingSeasonFolderFormat;
model.SeparatorStyle = _configProvider.SortingSeparatorStyle;
model.NumberStyle = _configProvider.SortingNumberStyle;
model.MultiEpisodeStyle = _configProvider.SortingMultiEpisodeStyle;
model.SceneName = _configProvider.SortingUseSceneName;
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name");
//Metadata
model.MetadataXbmcEnabled = _metadataProvider.GetSettings(typeof(Core.Providers.Metadata.Xbmc)).Enable;
model.MetadataUseBanners = _configProvider.MetadataUseBanners;
return View(model);
}
public ActionResult System()
{
var selectedAuthenticationType = _configFileProvider.AuthenticationType;
@ -271,7 +274,7 @@ public PartialViewResult AddProfile()
return GetQualityProfileView(qualityProfile);
}
public PartialViewResult GetQualityProfileView(QualityProfile profile)
public PartialViewResult GetQualityProfileView(QualityProfile profile)
{
var model = new QualityProfileModel();
model.QualityProfileId = profile.QualityProfileId;
@ -280,10 +283,19 @@ public PartialViewResult GetQualityProfileView(QualityProfile profile)
model.Sdtv = profile.Allowed.Contains(QualityTypes.SDTV);
model.Dvd = profile.Allowed.Contains(QualityTypes.DVD);
model.Hdtv = profile.Allowed.Contains(QualityTypes.HDTV);
model.Webdl = profile.Allowed.Contains(QualityTypes.WEBDL);
model.Webdl720p = profile.Allowed.Contains(QualityTypes.WEBDL720p);
model.Webdl1080p = profile.Allowed.Contains(QualityTypes.WEBDL1080p);
model.Bluray720p = profile.Allowed.Contains(QualityTypes.Bluray720p);
model.Bluray1080p = profile.Allowed.Contains(QualityTypes.Bluray1080p);
model.Cutoff = profile.Cutoff;
model.Cutoff = (int)profile.Cutoff;
model.SdtvId = QualityTypes.SDTV.Id;
model.DvdId = QualityTypes.DVD.Id;
model.HdtvId = QualityTypes.HDTV.Id;
model.Webdl720pId = QualityTypes.WEBDL720p.Id;
model.Webdl1080pId = QualityTypes.WEBDL1080p.Id;
model.Bluray720pId = QualityTypes.Bluray720p.Id;
model.Bluray1080pId = QualityTypes.Bluray1080p.Id;
return PartialView("QualityProfileItem", model);
}
@ -472,7 +484,7 @@ public JsonResult SaveQuality(QualityModel data)
var profile = new QualityProfile();
profile.QualityProfileId = profileModel.QualityProfileId;
profile.Name = profileModel.Name;
profile.Cutoff = profileModel.Cutoff;
profile.Cutoff = (QualityTypes)profileModel.Cutoff;
profile.Allowed = new List<QualityTypes>();
@ -485,8 +497,11 @@ public JsonResult SaveQuality(QualityModel data)
if (profileModel.Hdtv)
profile.Allowed.Add(QualityTypes.HDTV);
if (profileModel.Webdl)
profile.Allowed.Add(QualityTypes.WEBDL);
if (profileModel.Webdl720p)
profile.Allowed.Add(QualityTypes.WEBDL720p);
if (profileModel.Webdl1080p)
profile.Allowed.Add(QualityTypes.WEBDL1080p);
if (profileModel.Bluray720p)
profile.Allowed.Add(QualityTypes.Bluray720p);
@ -506,7 +521,8 @@ public JsonResult SaveQuality(QualityModel data)
qualityTypesFromDb.Single(q => q.QualityTypeId == 1).MaxSize = data.SdtvMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 2).MaxSize = data.DvdMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 4).MaxSize = data.HdtvMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 5).MaxSize = data.WebdlMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 5).MaxSize = data.Webdl720pMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 3).MaxSize = data.Webdl1080pMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 6).MaxSize = data.Bluray720pMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 7).MaxSize = data.Bluray1080pMaxSize;

View File

@ -6,6 +6,7 @@
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using LowercaseRoutesMVC;
using NLog.Config;
using Ninject;
using Ninject.Web.Mvc;
@ -26,7 +27,7 @@ public static void RegisterRoutes(RouteCollection routes)
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.MapRoute(
routes.MapRouteLowercase(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Series", action = "Index", id = UrlParameter.Optional } // Parameter defaults

View File

@ -7,7 +7,7 @@ namespace NzbDrone.Web.Helpers
{
public static class IsCurrentActionHelper
{
private static bool IsCurrentController(HtmlHelper helper, string actionName, string controllerName)
private static bool IsCurrentController(HtmlHelper helper, string controllerName)
{
var currentControllerName = (string) helper.ViewContext.RouteData.Values["controller"];
@ -17,12 +17,23 @@ private static bool IsCurrentController(HtmlHelper helper, string actionName, st
return false;
}
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName,
string controllerName)
private static bool IsCurrentAction(HtmlHelper helper, string actionName, string controllerName)
{
var currentControllerName = (string)helper.ViewContext.RouteData.Values["controller"];
var currentActionName = (string)helper.ViewContext.RouteData.Values["action"];
if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase) &&
currentActionName.Equals(actionName, StringComparison.CurrentCultureIgnoreCase))
return true;
return false;
}
public static string CurrentControllerLink(this HtmlHelper helper, string text, string actionName, string controllerName)
{
string result;
if (IsCurrentController(helper, actionName, controllerName))
if (IsCurrentController(helper, controllerName))
{
result = "<li class='current_page_item'>";
}
@ -33,5 +44,21 @@ public static string CurrentActionLink(this HtmlHelper helper, string text, stri
return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>";
}
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName, string controllerName)
{
string result;
if (IsCurrentAction(helper, actionName, controllerName))
{
result = "<li class='current_action'>";
}
else
{
result = "<li>";
}
return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>";
}
}
}

View File

@ -18,7 +18,8 @@ public class QualityModel
public int SdtvMaxSize { get; set; }
public int DvdMaxSize { get; set; }
public int HdtvMaxSize { get; set; }
public int WebdlMaxSize { get; set; }
public int Webdl720pMaxSize { get; set; }
public int Webdl1080pMaxSize { get; set; }
public int Bluray720pMaxSize { get; set; }
public int Bluray1080pMaxSize { get; set; }
}

View File

@ -18,7 +18,7 @@ public class QualityProfileModel
[DisplayName("Cut-off")]
[Required(ErrorMessage = "Valid Cut-off is Required")]
public QualityTypes Cutoff { get; set; }
public int Cutoff { get; set; }
[DisplayName("Allowed Qualities")]
public List<QualityTypes> Allowed { get; set; }
@ -26,20 +26,30 @@ public class QualityProfileModel
//Quality Booleans
[DisplayName("SDTV")]
public bool Sdtv { get; set; }
public int SdtvId { get; set; }
[DisplayName("DVD")]
public bool Dvd { get; set; }
public int DvdId { get; set; }
[DisplayName("HDTV")]
public bool Hdtv { get; set; }
public int HdtvId { get; set; }
[DisplayName("WEBDL")]
public bool Webdl { get; set; }
[DisplayName("WEBDL-720p")]
public bool Webdl720p { get; set; }
public int Webdl720pId { get; set; }
[DisplayName("WEBDL-1080p")]
public bool Webdl1080p { get; set; }
public int Webdl1080pId { get; set; }
[DisplayName("Bluray720p")]
public bool Bluray720p { get; set; }
public int Bluray720pId { get; set; }
[DisplayName("Bluray1080p")]
public bool Bluray1080p { get; set; }
public int Bluray1080pId { get; set; }
}
}

View File

@ -63,6 +63,9 @@
<Reference Include="EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.4.3.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="LowercaseRoutesMVC">
<HintPath>..\packages\LowercaseRoutesMVC.1.0.3\lib\LowercaseRoutesMVC.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
@ -412,6 +415,7 @@
<Content Include="Views\Settings\QualityProfileItem.cshtml" />
<Content Include="Views\System\Indexers.cshtml" />
<Content Include="Views\System\Config.cshtml" />
<Content Include="Views\Settings\_SettingsLayout.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
@ -473,9 +477,6 @@
<ItemGroup>
<Content Include="Views\Update\ViewLog.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Settings\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Shared\_ReferenceLayout.cshtml" />
</ItemGroup>

View File

@ -70,21 +70,19 @@ $(document).on('click', '.quality-selectee', function () {
var cleanId = getCleanId(this);
var cutoff = '#' + cleanId + '_Cutoff';
var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text();
var qualityId = $(this).attr('data-quality-id');
//Remove 'Unknown'
$(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); });
//Add option to cutoff SelectList
if ($(this).attr('checked')) {
$('<option>' + name + '</option>').appendTo(cutoff);
$('<option>' + name + '</option>').val(qualityId).appendTo(cutoff);
}
//Remove option from cutoff SelectList
else {
$(cutoff + ' option').each(function () {
if ($(this).text().indexOf(name) > -1)
$(cutoff + ' option').remove(':contains("' + $(this).text() + '")');
});
$(cutoff).find('option[value="' + qualityId + '"]').remove();
}
});

View File

@ -1,6 +1,10 @@
@using NzbDrone.Web.Helpers;
@model NzbDrone.Web.Models.DownloadClientSettingsModel
@{ Layout = null; }
@{
Layout = "_SettingsLayout.cshtml";
}
<style>
.downloadClient
{

View File

@ -1,34 +0,0 @@
@using NzbDrone.Web.Helpers
@{ViewBag.Title = "Settings";}
@section HeaderContent
{
@Html.IncludeCss("Settings.css")
@Html.IncludeCss("IndexerSettings.css")
@Html.IncludeCss("QualitySettings.css")
}
<div class="jquery-tabs">
<ul>
<li><a href="#Naming">Naming</a></li>
<li>@Html.ActionLink("Quality", "Quality", "Settings")</li>
<li>@Html.ActionLink("Indexers", "Indexers", "Settings")</li>
<li>@Html.ActionLink("Download Client", "DownloadClient", "Settings")</li>
<li>@Html.ActionLink("Notifications", "Notifications", "Settings")</li>
<li>@Html.ActionLink("System", "System", "Settings")</li>
<li>@Html.ActionLink("Misc", "Misc", "Settings")</li>
</ul>
<div id="Naming">@{ Html.RenderAction("Naming", "Settings"); }</div>
</div>
@section Scripts{
@Html.IncludeScript("NzbDrone/settings.js")
@Html.IncludeScript("NzbDrone/qualitySettings.js")
<script type="text/javascript">
$(document).ready(function () {
createExamples();
});
</script>
}

View File

@ -1,12 +1,16 @@
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.IndexerSettingsModel
@{ Layout = null; }
@{
Layout = "_SettingsLayout.cshtml";
}
<style>
.indexerStatusContainer {
margin-left: 14px;
}
</style>
<div class="indexerStatusContainer">
@Html.CheckBox("nzbMatrixStatus", @Model.NzbMatrixEnabled, new { @class = "indexerStatusButton" })
<label for="nzbMatrixStatus">NZBMatrix</label>
@ -177,7 +181,9 @@
}
</div>
<script type="text/javascript">
@section Scripts
{
<script type="text/javascript">
$(document).ready(function () {
//Allow unobstrusive validation of the AJAX loaded form
$.validator.unobtrusive.parse("#IndexersForm");
@ -318,3 +324,4 @@
$("#title_" + profileId).text(value);
}).keyup();
</script>
}

View File

@ -1,6 +1,9 @@
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.MiscSettingsModel
@{ Layout = null; }
@{
Layout = "_SettingsLayout.cshtml";
}
<div class="warningBox">
Enabling Backlog Searching can use lots of bandwidth and is not recommended for users with block Usenet accounts or bandwidth restrictions.

View File

@ -1,7 +1,6 @@
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.EpisodeNamingModel
@model NzbDrone.Web.Models.EpisodeNamingModel
@{
Layout = null;
Layout = "_SettingsLayout.cshtml";
}
<style>
#examples
@ -35,4 +34,12 @@
<button type="submit" class="save_button" disabled="disabled">
Save</button>
}
</div>
</div>
@section Scripts{
<script type="text/javascript">
$(document).ready(function () {
createExamples();
});
</script>
}

View File

@ -1,5 +1,9 @@
@model NzbDrone.Web.Models.NotificationSettingsModel
@{ Layout = null; }
@{
Layout = "_SettingsLayout.cshtml";
}
<style>
.notifier
{
@ -54,38 +58,42 @@
Save</button>
}
</div>
<script type="text/javascript">
$(document).ready(function () {
//Allow unobstrusive validation of the AJAX loaded form
$.validator.unobtrusive.parse('#NotificationForm');
//Validator Settings
var settings = $.data($('#NotificationForm')[0], 'validator').settings;
settings.ignore = [];
settings.focusInvalid = false;
settings.onfocusout = function (element) { $(element).valid(); };
@section Scripts
{
<script type="text/javascript">
$(document).ready(function() {
//Allow unobstrusive validation of the AJAX loaded form
$.validator.unobtrusive.parse('#NotificationForm');
var oldHighlight = settings.highlight;
var oldUnhighlight = settings.unhighlight;
//Validator Settings
var settings = $.data($('#NotificationForm')[0], 'validator').settings;
settings.ignore = [];
settings.focusInvalid = false;
settings.onfocusout = function(element) { $(element).valid(); };
settings.highlight = function (element, errorClass, validClass) {
oldHighlight(element, errorClass, validClass);
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
};
settings.unhighlight = function (element, errorClass, validClass) {
oldUnhighlight(element, errorClass, validClass);
var oldHighlight = settings.highlight;
var oldUnhighlight = settings.unhighlight;
var container = $(element).parents('div.ui-accordion-content');
if ($(container).children('.' + errorClass).length == 0)
settings.highlight = function(element, errorClass, validClass) {
oldHighlight(element, errorClass, validClass);
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
};
settings.unhighlight = function(element, errorClass, validClass) {
oldUnhighlight(element, errorClass, validClass);
var container = $(element).parents('div.ui-accordion-content');
if ($(container).children('.' + errorClass).length == 0)
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
};
});
$(document).on('change', '.checkClass', function() {
$("#NotificationForm").validate().form();
var container = $('div.ui-accordion-content');
if ($(container).children('.input-validation-error').length == 0)
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
};
});
$(document).on('change', '.checkClass', function () {
$("#NotificationForm").validate().form();
var container = $('div.ui-accordion-content');
if ($(container).children('.input-validation-error').length == 0)
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
});
</script>
});
</script>
}

View File

@ -1,11 +1,15 @@
@using NzbDrone.Core.Repository.Quality
@using NzbDrone.Web.Helpers;
@model NzbDrone.Web.Models.QualityModel
@{ Layout = null; }
@{
Layout = "_SettingsLayout.cshtml";
}
<div id="stylized">
@using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "QualityForm", name = "QualityForm" }))
@using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "QualityForm", name = "QualityForm", @class = "settingsForm" }))
{
<div id="top" class="settingsForm">
<div id="top">
<label class="labelClass">@Html.LabelFor(m => m.DefaultQualityProfileId)
<span class="small">@Html.DescriptionFor(m => m.DefaultQualityProfileId)</span>
</label>
@ -41,7 +45,7 @@
</div>
@Html.HiddenFor(m => m.SdtvMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</span>MB
</div>
<div class="slider-container">
<b>DVD</b>
@ -49,7 +53,7 @@
</div>
@Html.HiddenFor(m => m.DvdMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</span>MB
</div>
<div class="slider-container">
<b>HDTV</b>
@ -57,15 +61,15 @@
</div>
@Html.HiddenFor(m => m.HdtvMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</span>MB
</div>
<div class="slider-container">
<b>WEBDL</b>
<b>WEBDL-720p</b>
<div id="webdl-slider" class="slider">
</div>
@Html.HiddenFor(m => m.WebdlMaxSize, new { @class = "slider-value" })
@Html.HiddenFor(m => m.Webdl720pMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</span>MB
</div>
<div class="slider-container">
<b>Bluray 720p</b>
@ -73,7 +77,15 @@
</div>
@Html.HiddenFor(m => m.Bluray720pMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</span>MB
</div>
<div class="slider-container">
<b>WEBDL-1080p</b>
<div id="webdl-slider" class="slider">
</div>
@Html.HiddenFor(m => m.Webdl1080pMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</div>
<div class="slider-container">
<b>Bluray 1080p</b>
@ -81,7 +93,7 @@
</div>
@Html.HiddenFor(m => m.Bluray1080pMaxSize, new { @class = "slider-value" })
30 minute size: <span class="30-minute"></span>MB | 60 minute size: <span class="60-minute">
</span>MB
</span>MB
</div>
</div>
</div>
@ -90,12 +102,17 @@
Save</button>
}
</div>
<script type="text/javascript">
$(document).ready(function () {
setupSliders();
});
$('.quality-selectee').livequery(function () {
$(this).button();
});
</script>
@section Scripts {
@Html.IncludeScript("NzbDrone/qualitySettings.js")
<script type="text/javascript">
$(document).ready(function() {
setupSliders();
});
$('.quality-selectee').livequery(function() {
$(this).button();
});
</script>
}

View File

@ -20,20 +20,22 @@
@Html.LabelFor(x => x.Name)
@Html.TextBoxFor(x => x.Name, new { @class = "profileName_textbox" })
@Html.LabelFor(x => x.Cutoff)
@Html.DropDownListFor(m => m.Cutoff, new SelectList(Model.Allowed, Model.Cutoff))
@Html.DropDownListFor(m => m.Cutoff, new SelectList(Model.Allowed, "Id", "Name", Model.Cutoff))
</div>
<div class="qualitySelectees">
@Html.CheckBoxFor(m => m.Sdtv, new { @class = "quality-selectee" })
@Html.CheckBoxFor(m => m.Sdtv, new { @class = "quality-selectee", data_quality_id = Model.SdtvId })
@Html.LabelFor(m => m.Sdtv)
@Html.CheckBoxFor(m => m.Dvd, new { @class = "quality-selectee" })
@Html.CheckBoxFor(m => m.Dvd, new { @class = "quality-selectee", data_quality_id = Model.DvdId })
@Html.LabelFor(m => m.Dvd)
@Html.CheckBoxFor(m => m.Hdtv, new { @class = "quality-selectee" })
@Html.CheckBoxFor(m => m.Hdtv, new { @class = "quality-selectee", data_quality_id = Model.HdtvId })
@Html.LabelFor(m => m.Hdtv)
@Html.CheckBoxFor(m => m.Webdl, new { @class = "quality-selectee" })
@Html.LabelFor(m => m.Webdl)
@Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee" })
@Html.CheckBoxFor(m => m.Webdl720p, new { @class = "quality-selectee", data_quality_id = Model.Webdl720pId })
@Html.LabelFor(m => m.Webdl720p)
@Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee", data_quality_id = Model.Bluray720pId })
@Html.LabelFor(m => m.Bluray720p)
@Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee" })
@Html.CheckBoxFor(m => m.Webdl1080p, new { @class = "quality-selectee", data_quality_id = Model.Webdl1080pId })
@Html.LabelFor(m => m.Webdl1080p)
@Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee", data_quality_id = Model.Bluray1080pId })
@Html.LabelFor(m => m.Bluray1080p)
</div>
@Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" })

View File

@ -1,7 +1,9 @@
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.SystemSettingsModel
@{ Layout = null; }
@{
Layout = "_SettingsLayout.cshtml";
}
<div class="infoBox">
You must manually restart NzbDrone for these changes to take effect. (Automatic restart coming soon!)
@ -43,30 +45,33 @@
}
</div>
<script type="text/javascript">
$(document).ready(function () {
//Allow unobstrusive validation of the AJAX loaded form
$.validator.unobtrusive.parse('#SystemForm');
@section Scripts
{
<script type="text/javascript">
$(document).ready(function() {
//Allow unobstrusive validation of the AJAX loaded form
$.validator.unobtrusive.parse('#SystemForm');
//Validator Settings
var settings = $.data($('#SystemForm')[0], 'validator').settings;
settings.ignore = [];
settings.focusInvalid = false;
settings.onfocusout = function (element) { $(element).valid(); };
//Validator Settings
var settings = $.data($('#SystemForm')[0], 'validator').settings;
settings.ignore = [];
settings.focusInvalid = false;
settings.onfocusout = function(element) { $(element).valid(); };
var oldHighlight = settings.highlight;
var oldUnhighlight = settings.unhighlight;
var oldHighlight = settings.highlight;
var oldUnhighlight = settings.unhighlight;
settings.highlight = function (element, errorClass, validClass) {
oldHighlight(element, errorClass, validClass);
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
};
settings.unhighlight = function (element, errorClass, validClass) {
oldUnhighlight(element, errorClass, validClass);
settings.highlight = function(element, errorClass, validClass) {
oldHighlight(element, errorClass, validClass);
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
};
settings.unhighlight = function(element, errorClass, validClass) {
oldUnhighlight(element, errorClass, validClass);
var container = $(element).parents('div.ui-accordion-content');
if ($(container).children('.' + errorClass).length == 0)
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
};
});
</script>
var container = $(element).parents('div.ui-accordion-content');
if ($(container).children('.' + errorClass).length == 0)
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
};
});
</script>
}

View File

@ -0,0 +1,27 @@
@using NzbDrone.Web.Helpers
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
@section HeaderContent
{
@Html.IncludeCss("Settings.css")
@Html.IncludeCss("IndexerSettings.css")
@Html.IncludeCss("QualitySettings.css")
}
<ul class="settings-navigation">
@MvcHtmlString.Create(Html.CurrentActionLink("Naming", "Naming", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Quality", "Quality", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Indexers", "Indexers", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Download Client", "DownloadClient", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Notifications", "Notifications", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("System", "System", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Misc", "Misc", "Settings"))
</ul>
@RenderBody()
@section Scripts{
@Html.IncludeScript("NzbDrone/settings.js")
@RenderSection("Scripts", required: false)
}

View File

@ -24,12 +24,12 @@
<div id="centered">
<div id="menu">
<ul>
@MvcHtmlString.Create(Html.CurrentActionLink("Series", "Index", "Series"))
@MvcHtmlString.Create(Html.CurrentActionLink("Upcoming", "Index", "Upcoming"))
@MvcHtmlString.Create(Html.CurrentActionLink("History", "Index", "History"))
@MvcHtmlString.Create(Html.CurrentActionLink("Missing", "Index", "Missing"))
@MvcHtmlString.Create(Html.CurrentActionLink("Settings", "Index", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Logs", "Index", "Log"))
@MvcHtmlString.Create(Html.CurrentControllerLink("Series", "Index", "Series"))
@MvcHtmlString.Create(Html.CurrentControllerLink("Upcoming", "Index", "Upcoming"))
@MvcHtmlString.Create(Html.CurrentControllerLink("History", "Index", "History"))
@MvcHtmlString.Create(Html.CurrentControllerLink("Missing", "Index", "Missing"))
@MvcHtmlString.Create(Html.CurrentControllerLink("Settings", "Index", "Settings"))
@MvcHtmlString.Create(Html.CurrentControllerLink("Logs", "Index", "Log"))
</ul>
<input id="localSeriesLookup" type="text" />
</div>

View File

@ -16,6 +16,7 @@
<package id="jQuery.Validation" version="1.9" />
<package id="jQuery.Validation.Unobtrusive" version="2.0.20126.16343" />
<package id="jQuery.vsdoc" version="1.6" />
<package id="LowercaseRoutesMVC" version="1.0.3" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="2.0.2" />
<package id="MiniProfiler.MVC3" version="2.0.2" />

Binary file not shown.

View File

@ -0,0 +1,144 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>LowercaseRoutesMVC</name>
</assembly>
<members>
<member name="T:LowercaseRoutesMVC.RouteCollectionExtensions">
<summary>
Contains extension methods to map routes to lowercase URLs.
</summary>
</member>
<member name="M:LowercaseRoutesMVC.RouteCollectionExtensions.MapRouteLowercase(System.Web.Routing.RouteCollection,System.String,System.String)">
<summary>
Maps the specified URL route using a lowercase URL. Does not change casing in the querystring, if any.
</summary>
<param name="routes">A collection of routes for the application.</param>
<param name="name">The name of the route to map.</param>
<param name="url">The URL pattern for the route.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.RouteCollectionExtensions.MapRouteLowercase(System.Web.Routing.RouteCollection,System.String,System.String,System.Object)">
<summary>
Maps the specified URL route using a lowercase URL and sets default route values. Does not change casing in the querystring, if any.
</summary>
<param name="routes">A collection of routes for the application.</param>
<param name="name">The name of the route to map.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.RouteCollectionExtensions.MapRouteLowercase(System.Web.Routing.RouteCollection,System.String,System.String,System.String[])">
<summary>
Maps the specified URL route using a lowercase URL and sets the namespaces. Does not change casing in the querystring, if any.
</summary>
<param name="routes">A collection of routes for the application.</param>
<param name="name">The name of the route to map.</param>
<param name="url">The URL pattern for the route.</param>
<param name="namespaces">A set of namespaces for the application.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.RouteCollectionExtensions.MapRouteLowercase(System.Web.Routing.RouteCollection,System.String,System.String,System.Object,System.Object)">
<summary>
Maps the specified URL route using a lowercase URL and sets default route values and constraints. Does not change casing in the querystring, if any.
</summary>
<param name="routes">A collection of routes for the application.</param>
<param name="name">The name of the route to map.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<param name="constraints">A set of expressions that specify valid values for a URL parameter.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.RouteCollectionExtensions.MapRouteLowercase(System.Web.Routing.RouteCollection,System.String,System.String,System.Object,System.String[])">
<summary>
Maps the specified URL route using a lowercase URL and sets default route values and namespaces. Does not change casing in the querystring, if any.
</summary>
<param name="routes">A collection of routes for the application.</param>
<param name="name">The name of the route to map.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<param name="namespaces">A set of namespaces for the application.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.RouteCollectionExtensions.MapRouteLowercase(System.Web.Routing.RouteCollection,System.String,System.String,System.Object,System.Object,System.String[])">
<summary>
Maps the specified URL route and sets default route values, constraints, and namespaces. Does not change casing in the querystring, if any.
</summary>
<param name="routes">A collection of routes for the application.</param>
<param name="name">The name of the route to map.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<param name="constraints">A set of expressions that specify valid values for a URL parameter.</param>
<param name="namespaces">A set of namespaces for the application.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="T:LowercaseRoutesMVC.AreaRegistrationContextExtensions">
<summary>
Contains extension methods to map routes in Areas to lowercase URLs.
</summary>
</member>
<member name="M:LowercaseRoutesMVC.AreaRegistrationContextExtensions.MapRouteLowercase(System.Web.Mvc.AreaRegistrationContext,System.String,System.String)">
<summary>
Maps the specified URL route using a lowercase URL and associates it with the area that is specified by the AreaName property. Does not change casing in the querystring, if any.
</summary>
<param name="context">The context that encapsulates the information that is required in order to register an area within an ASP.NET MVC application.</param>
<param name="name">The name of the route.</param>
<param name="url">The URL pattern for the route.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.AreaRegistrationContextExtensions.MapRouteLowercase(System.Web.Mvc.AreaRegistrationContext,System.String,System.String,System.Object)">
<summary>
Maps the specified URL route using a lowercase URL and associates it with the area that is specified by the AreaName property, using the specified route default values. Does not change casing in the querystring, if any.
</summary>
<param name="context">The context that encapsulates the information that is required in order to register an area within an ASP.NET MVC application.</param>
<param name="name">The name of the route.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.AreaRegistrationContextExtensions.MapRouteLowercase(System.Web.Mvc.AreaRegistrationContext,System.String,System.String,System.String[])">
<summary>
Maps the specified URL route using a lowercase URL and associates it with the area that is specified by the AreaName property, using the specified namespaces. Does not change casing in the querystring, if any.
</summary>
<param name="context">The context that encapsulates the information that is required in order to register an area within an ASP.NET MVC application.</param>
<param name="name">The name of the route.</param>
<param name="url">The URL pattern for the route.</param>
<param name="namespaces">A set of namespaces for the application.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.AreaRegistrationContextExtensions.MapRouteLowercase(System.Web.Mvc.AreaRegistrationContext,System.String,System.String,System.Object,System.Object)">
<summary>
Maps the specified URL route using a lowercase URL and associates it with the area that is specified by the AreaName property, using the specified route default values and constraints. Does not change casing in the querystring, if any.
</summary>
<param name="context">The context that encapsulates the information that is required in order to register an area within an ASP.NET MVC application.</param>
<param name="name">The name of the route.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<param name="constraints">A set of expressions that specify valid values for a URL parameter.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.AreaRegistrationContextExtensions.MapRouteLowercase(System.Web.Mvc.AreaRegistrationContext,System.String,System.String,System.Object,System.String[])">
<summary>
Maps the specified URL route using a lowercase URL and associates it with the area that is specified by the AreaName property, using the specified route default values and namespaces. Does not change casing in the querystring, if any.
</summary>
<param name="context">The context that encapsulates the information that is required in order to register an area within an ASP.NET MVC application.</param>
<param name="name">The name of the route.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<param name="namespaces">A set of namespaces for the application.</param>
<returns>A reference to the mapped route.</returns>
</member>
<member name="M:LowercaseRoutesMVC.AreaRegistrationContextExtensions.MapRouteLowercase(System.Web.Mvc.AreaRegistrationContext,System.String,System.String,System.Object,System.Object,System.String[])">
<summary>
Maps the specified URL route using a lowercase URL and associates it with the area that is specified by the AreaName property, using the specified route default values, constraints, and namespaces. Does not change casing in the querystring, if any.
</summary>
<param name="context">The context that encapsulates the information that is required in order to register an area within an ASP.NET MVC application.</param>
<param name="name">The name of the route.</param>
<param name="url">The URL pattern for the route.</param>
<param name="defaults">An object that contains default route values.</param>
<param name="constraints">A set of expressions that specify valid values for a URL parameter.</param>
<param name="namespaces">A set of namespaces for the application.</param>
<returns>A reference to the mapped route.</returns>
</member>
</members>
</doc>

Binary file not shown.

Binary file not shown.