From 49f086cf19eb0f8bdbc91bbe153c66e071a5b4c0 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 13 Oct 2012 14:15:21 -0700 Subject: [PATCH 1/8] Renamed Quality to QualityModel --- NzbDrone.Core.Test/EpisodeParseResultTest.cs | 16 +++---- .../NzbDrone.Core.Test.ncrunchproject | 3 ++ .../AcceptableSizeSpecificationFixture.cs | 4 +- ...AllowedReleaseGroupSpecificationFixture.cs | 2 +- ...ityAllowedByProfileSpecificationFixtrue.cs | 2 +- .../QualityUpgradeSpecificationFixture.cs | 2 +- .../UpgradeDiskSpecificationFixtrue.cs | 4 +- .../UpgradeHistorySpecificationFixtrue.cs | 14 +++--- .../MoveEpisodeFileFixture.cs | 2 +- .../SabProviderTests/QueueFixture.cs | 16 +++---- .../ProviderTests/DownloadProviderFixture.cs | 8 ++-- .../ProcessDailySearchResultsFixture.cs | 20 ++++---- .../ProcessSearchResultsFixture.cs | 26 +++++----- NzbDrone.Core.Test/QualityTest.cs | 48 +++++++++---------- NzbDrone.Core/Model/EpisodeParseResult.cs | 2 +- .../Model/{Quality.cs => QualityModel.cs} | 26 +++++----- NzbDrone.Core/Model/SeasonParseResult.cs | 2 +- NzbDrone.Core/Parser.cs | 4 +- .../QualityUpgradeSpecification.cs | 2 +- .../UpgradeDiskSpecification.cs | 2 +- NzbDrone.Core/Providers/DiskScanProvider.cs | 2 +- NzbDrone.Core/Providers/HistoryProvider.cs | 4 +- NzbDrone.Core/Providers/SignalRProvider.cs | 2 +- NzbDrone.Core/Repository/EpisodeFile.cs | 4 +- 24 files changed, 110 insertions(+), 107 deletions(-) rename NzbDrone.Core/Model/{Quality.cs => QualityModel.cs} (73%) diff --git a/NzbDrone.Core.Test/EpisodeParseResultTest.cs b/NzbDrone.Core.Test/EpisodeParseResultTest.cs index a98b7526a..7cb6ac847 100644 --- a/NzbDrone.Core.Test/EpisodeParseResultTest.cs +++ b/NzbDrone.Core.Test/EpisodeParseResultTest.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test parseResult.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test parseResult.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test parseResult.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test parseResult.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test 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 @@ namespace NzbDrone.Core.Test 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 @@ namespace NzbDrone.Core.Test 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 @@ namespace NzbDrone.Core.Test 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]"); diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject index 19f185295..35a316e01 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject @@ -23,5 +23,8 @@ NzbDrone.Core.Test.Integeration.ServiceIntegerationFixture.should_be_able_to_submit_exceptions + + NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests.ImportFileFixture.import_unparsable_file_should_skip + \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs index 300082d67..de8d9d381 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests { SeriesTitle = "Title", Language = LanguageType.English, - Quality = new Quality(QualityTypes.SDTV, true), + Quality = new QualityModel(QualityTypes.SDTV, true), EpisodeNumbers = new List { 3, 4 }, SeasonNumber = 12, AirDate = DateTime.Now.AddDays(-12).Date @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests { SeriesTitle = "Title", Language = LanguageType.English, - Quality = new Quality(QualityTypes.SDTV, true), + Quality = new QualityModel(QualityTypes.SDTV, true), EpisodeNumbers = new List { 3 }, SeasonNumber = 12, AirDate = DateTime.Now.AddDays(-12).Date diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs index 760496dcb..223c34201 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests { SeriesTitle = "Title", Language = LanguageType.English, - Quality = new Quality(QualityTypes.SDTV, true), + Quality = new QualityModel(QualityTypes.SDTV, true), EpisodeNumbers = new List { 3 }, SeasonNumber = 12, AirDate = DateTime.Now.AddDays(-12).Date, diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs index 86158b9c1..6a75c9c7f 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests parseResult = new EpisodeParseResult { Series = fakeSeries, - Quality = new Quality(QualityTypes.DVD, true), + Quality = new QualityModel(QualityTypes.DVD, true), EpisodeNumbers = new List { 3 }, SeasonNumber = 12, }; diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs index 83f6c1ea0..f9942d3a2 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests [TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, Result = true)] public bool IsUpgradeTest(QualityTypes current, bool currentProper, QualityTypes newQuality, bool newProper, QualityTypes cutoff) { - return new QualityUpgradeSpecification().IsSatisfiedBy(new Quality(current, currentProper), new Quality(newQuality, newProper), cutoff); + return new QualityUpgradeSpecification().IsSatisfiedBy(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper), cutoff); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeDiskSpecificationFixtrue.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeDiskSpecificationFixtrue.cs index bd8a2a39f..5a6789f1b 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeDiskSpecificationFixtrue.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeDiskSpecificationFixtrue.cs @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests parseResultMulti = new EpisodeParseResult { Series = fakeSeries, - Quality = new Quality(QualityTypes.DVD, true), + Quality = new QualityModel(QualityTypes.DVD, true), EpisodeNumbers = new List { 3, 4 }, SeasonNumber = 12, }; @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests parseResultSingle = new EpisodeParseResult { Series = fakeSeries, - Quality = new Quality(QualityTypes.DVD, true), + Quality = new QualityModel(QualityTypes.DVD, true), EpisodeNumbers = new List { 3 }, SeasonNumber = 12, }; diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs index 85e0ff0fe..07928f1cc 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs @@ -22,8 +22,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests parseResultMulti = new EpisodeParseResult { Series = fakeSeries, - Quality = new Quality(QualityTypes.DVD, true), + Quality = new QualityModel(QualityTypes.DVD, true), EpisodeNumbers = new List { 3, 4 }, SeasonNumber = 12, }; @@ -46,13 +46,13 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests parseResultSingle = new EpisodeParseResult { Series = fakeSeries, - Quality = new Quality(QualityTypes.DVD, true), + Quality = new QualityModel(QualityTypes.DVD, true), EpisodeNumbers = new List { 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 { new Episode { SeasonNumber = 12, EpisodeNumber = 3 } }; var doubleEpisodeList = new List { @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 3)).Returns(firstQuality); Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 4)).Returns(secondQuality); - Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 5)).Returns(null); + Mocker.GetMock().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 5)).Returns(null); } private void WithFirstReportUpgradable() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs index a45f4fab3..29161b848 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests .Returns(fi); Mocker.GetMock() - .Setup(s => s.GetDownloadTitle(It.Is(e => e.Quality == new Quality{ QualityType = QualityTypes.WEBDL, Proper = false }))) + .Setup(s => s.GetDownloadTitle(It.Is(e => e.Quality == new QualityModel{ QualityType = QualityTypes.WEBDL, Proper = false }))) .Returns(message); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs index 95445c30e..49ced0e0e 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List { 5 }, SeasonNumber = 1, - Quality = new Quality { QualityType = QualityTypes.SDTV, Proper = false }, + Quality = new QualityModel { QualityType = QualityTypes.SDTV, Proper = false }, Series = new Series { Title = "30 Rock", CleanTitle = Parser.NormalizeTitle("30 Rock") }, }; @@ -145,7 +145,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests var parseResult = new EpisodeParseResult { - Quality = new Quality { QualityType = QualityTypes.Bluray720p, Proper = false }, + Quality = new QualityModel { QualityType = QualityTypes.Bluray720p, Proper = false }, AirDate = new DateTime(2011, 12, 01), Series = new Series { Title = "The Dailyshow", CleanTitle = Parser.NormalizeTitle("The Dailyshow"), IsDaily = true }, }; @@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests var parseResult = new EpisodeParseResult { - Quality = new Quality { QualityType = QualityTypes.Bluray720p, Proper = false }, + Quality = new QualityModel { QualityType = QualityTypes.Bluray720p, Proper = false }, FullSeason = true, SeasonNumber = 5, Series = new Series { Title = "My Name is earl", CleanTitle = Parser.NormalizeTitle("My Name is earl") }, @@ -191,7 +191,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new Quality { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { QualityType = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -215,7 +215,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new Quality { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { QualityType = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -237,7 +237,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new Quality { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { QualityType = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -259,7 +259,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new Quality { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { QualityType = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -278,7 +278,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List { 1 }, SeasonNumber = 2, - Quality = new Quality { QualityType = QualityTypes.Bluray1080p, Proper = true }, + Quality = new QualityModel { QualityType = QualityTypes.Bluray1080p, Proper = true }, Series = new Series { Title = "Test", CleanTitle = Parser.NormalizeTitle("Test") }, }; diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs index 179478611..e59031378 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.ProviderTests .Setup(c => c.GetEpisodesByParseResult(It.IsAny())).Returns(episodes); return Builder.CreateNew() - .With(c => c.Quality = new Quality(QualityTypes.DVD, false)) + .With(c => c.Quality = new QualityModel(QualityTypes.DVD, false)) .With(c => c.Series = Builder.CreateNew().Build()) .With(c => c.EpisodeNumbers = new List{2}) .Build(); @@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test.ProviderTests { AirDate = DateTime.Now, EpisodeNumbers = episodes.ToList(), - Quality = new Quality(quality, proper), + Quality = new QualityModel(quality, proper), SeasonNumber = seasons, Series = series, EpisodeTitle = title @@ -215,7 +215,7 @@ namespace NzbDrone.Core.Test.ProviderTests 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 @@ namespace NzbDrone.Core.Test.ProviderTests 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", }; diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs index a1dbf2041..9d3b1173a 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs @@ -93,9 +93,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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(); @@ -123,7 +123,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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,9 +212,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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(); @@ -244,7 +244,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests var parseResults = Builder.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(); diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs index d649b0800..5320eb748 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs @@ -91,10 +91,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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(); @@ -125,7 +125,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 2) .With(e => e.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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 { 1, 2, 3, 4, 5 }) .Build(); @@ -302,9 +302,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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(); @@ -336,10 +336,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests .All() .With(e => e.SeasonNumber = 1) .With(e => e.EpisodeNumbers = new List { 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(); diff --git a/NzbDrone.Core.Test/QualityTest.cs b/NzbDrone.Core.Test/QualityTest.cs index 176005171..c55747182 100644 --- a/NzbDrone.Core.Test/QualityTest.cs +++ b/NzbDrone.Core.Test/QualityTest.cs @@ -13,8 +13,8 @@ namespace NzbDrone.Core.Test [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 @@ namespace NzbDrone.Core.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 @@ namespace NzbDrone.Core.Test [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 @@ namespace NzbDrone.Core.Test [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 @@ namespace NzbDrone.Core.Test [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 @@ namespace NzbDrone.Core.Test [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,8 +69,8 @@ namespace NzbDrone.Core.Test [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(); } @@ -79,8 +79,8 @@ namespace NzbDrone.Core.Test [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 +88,8 @@ namespace NzbDrone.Core.Test [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 +97,8 @@ namespace NzbDrone.Core.Test [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 +106,8 @@ namespace NzbDrone.Core.Test [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 +116,8 @@ namespace NzbDrone.Core.Test [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(); diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index e2385d5ff..12a8201a7 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Model public DateTime? AirDate { get; set; } - public Quality Quality { get; set; } + public QualityModel Quality { get; set; } public LanguageType Language { get; set; } diff --git a/NzbDrone.Core/Model/Quality.cs b/NzbDrone.Core/Model/QualityModel.cs similarity index 73% rename from NzbDrone.Core/Model/Quality.cs rename to NzbDrone.Core/Model/QualityModel.cs index 28b0b4012..ed545ae98 100644 --- a/NzbDrone.Core/Model/Quality.cs +++ b/NzbDrone.Core/Model/QualityModel.cs @@ -3,21 +3,21 @@ using NzbDrone.Core.Repository.Quality; namespace NzbDrone.Core.Model { - public class Quality : IComparable + public class QualityModel : IComparable { public QualityTypes QualityType { 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; Proper = proper; } - public int CompareTo(Quality other) + public int CompareTo(QualityModel other) { if (other.QualityType > QualityType) return -1; @@ -37,12 +37,12 @@ namespace NzbDrone.Core.Model 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,22 +55,22 @@ namespace NzbDrone.Core.Model 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; } - 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; } @@ -97,7 +97,7 @@ namespace NzbDrone.Core.Model } } - public bool Equals(Quality other) + public bool Equals(QualityModel other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; @@ -108,8 +108,8 @@ namespace NzbDrone.Core.Model { 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); } } } diff --git a/NzbDrone.Core/Model/SeasonParseResult.cs b/NzbDrone.Core/Model/SeasonParseResult.cs index 9422e35a6..49ae63ba2 100644 --- a/NzbDrone.Core/Model/SeasonParseResult.cs +++ b/NzbDrone.Core/Model/SeasonParseResult.cs @@ -6,7 +6,7 @@ internal int SeasonNumber { get; set; } internal int Year { get; set; } - public Quality Quality { get; set; } + public QualityModel Quality { get; set; } public override string ToString() { diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index a151e0ef5..e087af92f 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -245,13 +245,13 @@ namespace NzbDrone.Core 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 { QualityType = QualityTypes.Unknown }; result.Proper = (normalizedName.Contains("proper") || normalizedName.Contains("repack")); if (normalizedName.Contains("dvd") || normalizedName.Contains("bdrip") || normalizedName.Contains("brrip")) diff --git a/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs index f578a710c..594626205 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine { 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) { diff --git a/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs index ee9a500e0..58711f6bc 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine foreach (var file in _episodeProvider.GetEpisodesByParseResult(subject).Select(c => c.EpisodeFile).Where(c => c != null)) { logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper); - if (!_qualityUpgradeSpecification.IsSatisfiedBy(new Quality { QualityType = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff)) + if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { QualityType = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff)) return false; } diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index bf9e2db24..e6ae304d8 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -202,7 +202,7 @@ namespace NzbDrone.Core.Providers var parseResult = Parser.ParsePath(episodeFile.Path); parseResult.Series = series; - parseResult.Quality = new Quality{ QualityType = episodeFile.Quality, Proper = episodeFile.Proper }; + parseResult.Quality = new QualityModel{ QualityType = episodeFile.Quality, Proper = episodeFile.Proper }; var message = _downloadProvider.GetDownloadTitle(parseResult); diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index 807c39fb6..520ea18a3 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Providers 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(@"SELECT TOP 1 History.Quality , History.IsProper FROM History INNER JOIN Episodes ON History.EpisodeId = Episodes.EpisodeId @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Providers 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) diff --git a/NzbDrone.Core/Providers/SignalRProvider.cs b/NzbDrone.Core/Providers/SignalRProvider.cs index b815d1466..01769116d 100644 --- a/NzbDrone.Core/Providers/SignalRProvider.cs +++ b/NzbDrone.Core/Providers/SignalRProvider.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Providers { 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 { diff --git a/NzbDrone.Core/Repository/EpisodeFile.cs b/NzbDrone.Core/Repository/EpisodeFile.cs index 32758b8ce..b4d928d60 100644 --- a/NzbDrone.Core/Repository/EpisodeFile.cs +++ b/NzbDrone.Core/Repository/EpisodeFile.cs @@ -38,11 +38,11 @@ namespace NzbDrone.Core.Repository 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 { From 92acb4c0498bcb7a1b146bc2770331d110f92367 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 13 Oct 2012 17:36:16 -0700 Subject: [PATCH 2/8] QualityTypes no longer an enum --- NzbDrone.Core.Test/IndexerTests.cs | 13 +- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 4 +- .../{ => ParserFixture}/ParserTest.cs | 69 +-------- .../ParserFixture/QualityParserTests.cs | 97 ++++++++++++ ...ityAllowedByProfileSpecificationFixtrue.cs | 30 ++-- .../QualityUpgradeSpecificationFixture.cs | 28 ++-- .../UpgradeHistorySpecificationFixtrue.cs | 4 +- .../ImportFileFixture.cs | 14 +- .../MoveEpisodeFileFixture.cs | 2 +- .../SabProviderTests/QueueFixture.cs | 78 ++++++---- .../ProviderTests/DownloadProviderFixture.cs | 24 +-- .../ProviderTests/EpisodeProviderTest.cs | 7 +- .../ProviderTests/HistoryProviderTest.cs | 29 +++- .../ProviderTests/MediaFileProviderTest.cs | 18 ++- .../CleanUpDatabaseFixture.cs | 7 +- .../SearchHistoryProviderTest.cs | 4 + .../ProcessDailySearchResultsFixture.cs | 6 +- .../ProcessSearchResultsFixture.cs | 8 +- NzbDrone.Core.Test/QualityTest.cs | 1 - NzbDrone.Core.Test/QualityTypesTest.cs | 127 +++++++++++++++ NzbDrone.Core/Datastore/CustomeMapper.cs | 27 +++- NzbDrone.Core/Model/QualityModel.cs | 18 +-- NzbDrone.Core/NzbDrone.Core.csproj | 4 +- NzbDrone.Core/Parser.cs | 30 ++-- .../AcceptableSizeSpecification.cs | 2 +- .../QualityAllowedByProfileSpecification.cs | 2 +- .../QualityUpgradeSpecification.cs | 4 +- .../UpgradeDiskSpecification.cs | 2 +- NzbDrone.Core/Providers/DiskScanProvider.cs | 4 +- NzbDrone.Core/Providers/DownloadProvider.cs | 8 +- NzbDrone.Core/Providers/SearchProvider.cs | 4 +- NzbDrone.Core/Providers/SignalRProvider.cs | 2 +- NzbDrone.Core/Repository/EpisodeFile.cs | 2 +- .../Repository/Quality/QualityProfile.cs | 4 +- .../Repository/Quality/QualityTypes.cs | 146 ++++++++++++++---- .../Repository/Search/SearchHistoryItem.cs | 2 +- .../Controllers/SettingsController.cs | 1 + 37 files changed, 585 insertions(+), 247 deletions(-) rename NzbDrone.Core.Test/{ => ParserFixture}/ParserTest.cs (81%) create mode 100644 NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs create mode 100644 NzbDrone.Core.Test/QualityTypesTest.cs diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 153eea289..44094123d 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -138,10 +138,14 @@ namespace NzbDrone.Core.Test ExceptionVerification.IgnoreWarns(); } - - [TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)] - public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality) + [Test] + public void custome_parser_partial_success() { + const string title = "Adventure.Inc.S03E19.DVDRip.XviD-OSiTV"; + const int season = 3; + const int episode = 19; + var quality = QualityTypes.DVD; + const string summary = "My fake summary"; var fakeSettings = Builder.CreateNew().Build(); @@ -160,10 +164,9 @@ namespace NzbDrone.Core.Test Assert.AreEqual(LanguageType.Finnish, result.Language); Assert.AreEqual(season, result.SeasonNumber); Assert.AreEqual(episode, result.EpisodeNumbers[0]); - Assert.AreEqual(quality, result.Quality.QualityType); + Assert.AreEqual(quality, result.Quality.Quality); } - [TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")] public void custome_parser_full_parse(string title) { diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 91bf04d2c..5e25afc47 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -137,12 +137,14 @@ + + @@ -226,7 +228,7 @@ - + diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserFixture/ParserTest.cs similarity index 81% rename from NzbDrone.Core.Test/ParserTest.cs rename to NzbDrone.Core.Test/ParserFixture/ParserTest.cs index 40a78a785..42992960f 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserFixture/ParserTest.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test +namespace NzbDrone.Core.Test.ParserFixture { [TestFixture] // ReSharper disable InconsistentNaming @@ -126,73 +126,6 @@ namespace NzbDrone.Core.Test ExceptionVerification.IgnoreWarns(); } - [TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD, false)] - [TestCase("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD, false)] - [TestCase("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD, false)] - [TestCase("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV, false)] - [TestCase("this has no extention or periods HDTV", QualityTypes.SDTV, false)] - [TestCase("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV, false)] - [TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD, false)] - [TestCase("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD, false)] - [TestCase("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV, false)] - [TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV, false)] - [TestCase("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL, false)] - [TestCase("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV, false)] - [TestCase("Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV, false)] - [TestCase("Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV, false)] - [TestCase("Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV, false)] - [TestCase("Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV, false)] - [TestCase("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown, false)] - [TestCase("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV, false)] - [TestCase("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV, false)] - [TestCase("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p, false)] - [TestCase("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p, false)] - [TestCase("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL, false)] - [TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)] - [TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)] - [TestCase("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown, false)] - [TestCase("(NZB)", 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 })] diff --git a/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs b/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs new file mode 100644 index 000000000..23395c670 --- /dev/null +++ b/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs @@ -0,0 +1,97 @@ +// ReSharper disable RedundantUsingDirective +using System; +using System.Linq; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Common; +using NzbDrone.Common.Contract; +using NzbDrone.Core.Model; +using NzbDrone.Core.Repository.Quality; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.ParserFixture +{ + [TestFixture] + // ReSharper disable InconsistentNaming + public class QualityParserTests : CoreTest + { + public static object[] QualityParserCases = + { + new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD, false }, + new object[] { "WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD, false }, + new object[] { "WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD, false }, + new object[] { "Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV, false }, + new object[] { "this has no extention or periods HDTV", QualityTypes.SDTV, false }, + new object[] { "Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV, false }, + new object[] { "The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD, false }, + new object[] { "The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD, false }, + new object[] { "The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV, false }, + new object[] { "Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV, false }, + new object[] { "Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL, false }, + new object[] { "Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV, false }, + new object[] { "Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV, false }, + new object[] { "Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV, false }, + new object[] { "Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV, false }, + new object[] { "Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV, false }, + new object[] { "Sonny.With.a.Chance.S02E15", QualityTypes.Unknown, false }, + new object[] { "Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV, false }, + new object[] { "Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV, false }, + new object[] { "Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p, false }, + new object[] { "Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p, false }, + new object[] { "Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL, false }, + new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false }, + new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false }, + new object[] { "Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown, false }, + new object[] { "(NZB)", QualityTypes.Unknown, false }, + new object[] { "S07E23 - [HDTV].mkv ", QualityTypes.HDTV, false }, + new object[] { "S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL, false }, + new object[] { "S07E23.mkv ", QualityTypes.HDTV, false }, + new object[] { "S07E23 .avi ", QualityTypes.SDTV, false }, + new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false }, + new object[] { "WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p, false }, + new object[] { "The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.Unknown, false }, + new object[] { "Nikita S02E01 HDTV XviD 2HD", QualityTypes.SDTV, false }, + new object[] { "Gossip Girl S05E11 PROPER HDTV XviD 2HD", QualityTypes.SDTV, true }, + new object[] { "The Jonathan Ross Show S02E08 HDTV x264 FTP", QualityTypes.SDTV, false }, + new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-TLA", QualityTypes.SDTV, false }, + new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-REPACK-TLA", QualityTypes.SDTV, true }, + new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3-REPACK.-HELLYWOOD.avi", QualityTypes.DVD, true }, + new object[] { "Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", QualityTypes.HDTV, true }, + new object[] { "The Real Housewives of Vancouver S01E04 DSR x264 2HD", QualityTypes.SDTV, false }, + new object[] { "Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", QualityTypes.SDTV, false }, + new object[] { "Vanguard S01E04 Mexicos Death Train 720 WEB DL", QualityTypes.WEBDL, false }, + new object[] { "Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", QualityTypes.WEBDL, false }, + new object[] { "Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL, false }, + new object[] { "Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", QualityTypes.WEBDL, false }, + new object[] { "Fringe.S04E22.720p.WEB.DL.DD5.1.H264-EbP", QualityTypes.WEBDL, false } + }; + + public static object[] SelfQualityParserCases = + { + new object[] { QualityTypes.SDTV }, + new object[] { QualityTypes.DVD }, + new object[] { QualityTypes.HDTV }, + new object[] { QualityTypes.WEBDL }, + new object[] { QualityTypes.Bluray720p }, + new object[] { QualityTypes.Bluray1080p } + }; + + [Test, TestCaseSource("QualityParserCases")] + public void quality_parse(string postTitle, QualityTypes quality, bool proper) + { + var result = Parser.ParseQuality(postTitle); + result.Quality.Should().Be(quality); + result.Proper.Should().Be(proper); + } + + [Test, TestCaseSource("SelfQualityParserCases")] + public void parsing_our_own_quality_enum(QualityTypes quality) + { + var fileName = String.Format("My series S01E01 [{0}]", quality); + var result = Parser.ParseQuality(fileName); + result.Quality.Should().Be(quality); + } + } +} diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs index 6a75c9c7f..3af218337 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityAllowedByProfileSpecificationFixtrue.cs @@ -18,10 +18,21 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests public class QualityAllowedByProfileSpecificationFixtrue : CoreTest { private QualityAllowedByProfileSpecification _qualityAllowedByProfile; - - private EpisodeParseResult parseResult; + public static object[] AllowedTestCases = + { + new object[] { QualityTypes.DVD }, + new object[] { QualityTypes.HDTV }, + new object[] { QualityTypes.Bluray1080p } + }; + + public static object[] DeniedTestCases = + { + new object[] { QualityTypes.SDTV }, + new object[] { QualityTypes.WEBDL }, + new object[] { QualityTypes.Bluray720p } + }; [SetUp] public void Setup() @@ -41,29 +52,22 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests }; } - - - [TestCase(QualityTypes.DVD)] - [TestCase(QualityTypes.HDTV)] - [TestCase(QualityTypes.Bluray1080p)] + [Test, TestCaseSource("AllowedTestCases")] public void should_allow_if_quality_is_defined_in_profile(QualityTypes qualityType) { - parseResult.Quality.QualityType = qualityType; + parseResult.Quality.Quality = qualityType; parseResult.Series.QualityProfile.Allowed = new List { QualityTypes.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.DVD, QualityTypes.HDTV, QualityTypes.Bluray1080p }; _qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeFalse(); } - } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs index f9942d3a2..7e7e9c482 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs @@ -1,6 +1,7 @@ // ReSharper disable RedundantUsingDirective using System.Linq; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.DecisionEngine; @@ -13,18 +14,23 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests // ReSharper disable InconsistentNaming public class QualityUpgradeSpecificationFixture : CoreTest { - - [TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, Result = true)] - [TestCase(QualityTypes.WEBDL, false, QualityTypes.WEBDL, true, QualityTypes.WEBDL, Result = true)] - [TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, false, QualityTypes.SDTV, Result = false)] - [TestCase(QualityTypes.SDTV, false, QualityTypes.DVD, true, QualityTypes.SDTV, Result = false)] - [TestCase(QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.Bluray720p, Result = false)] - [TestCase(QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.WEBDL, Result = false)] - [TestCase(QualityTypes.WEBDL, false, QualityTypes.WEBDL, false, QualityTypes.WEBDL, Result = false)] - [TestCase(QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, Result = true)] - public bool IsUpgradeTest(QualityTypes current, bool currentProper, QualityTypes newQuality, bool newProper, QualityTypes cutoff) + public static object[] IsUpgradeTestCases = { - return new QualityUpgradeSpecification().IsSatisfiedBy(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper), cutoff); + new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true }, + new object[] { QualityTypes.WEBDL, false, QualityTypes.WEBDL, true, QualityTypes.WEBDL, true }, + new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, false, QualityTypes.SDTV, false }, + new object[] { QualityTypes.SDTV, false, QualityTypes.DVD, true, QualityTypes.SDTV, false }, + new object[] { QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.Bluray720p, false }, + new object[] { QualityTypes.WEBDL, false, QualityTypes.HDTV, true, QualityTypes.WEBDL, false }, + new object[] { QualityTypes.WEBDL, false, QualityTypes.WEBDL, false, QualityTypes.WEBDL, false }, + new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true } + }; + + [Test, TestCaseSource("IsUpgradeTestCases")] + public void IsUpgradeTest(QualityTypes current, bool currentProper, QualityTypes newQuality, bool newProper, QualityTypes cutoff, bool expected) + { + new QualityUpgradeSpecification().IsSatisfiedBy(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper), cutoff) + .Should().Be(expected); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs index 07928f1cc..fafc64c94 100644 --- a/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs +++ b/NzbDrone.Core.Test/ProviderTests/DecisionEngineTests/UpgradeHistorySpecificationFixtrue.cs @@ -71,12 +71,12 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests private void WithFirstReportUpgradable() { - firstQuality.QualityType = QualityTypes.SDTV; + firstQuality.Quality = QualityTypes.SDTV; } private void WithSecondReportUpgradable() { - secondQuality.QualityType = QualityTypes.SDTV; + secondQuality.Quality = QualityTypes.SDTV; } diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs index 21b9acf69..1812d841b 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs @@ -20,6 +20,13 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests // ReSharper disable InconsistentNaming public class ImportFileFixture : CoreTest { + public static object[] ImportTestCases = + { + new object[] { QualityTypes.SDTV }, + new object[] { QualityTypes.DVD }, + new object[] { QualityTypes.HDTV } + }; + [Test] public void import_new_file_should_succeed() { @@ -49,9 +56,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests } - [TestCase(QualityTypes.SDTV, false)] - [TestCase(QualityTypes.DVD, true)] - [TestCase(QualityTypes.HDTV, false)] + [Test, TestCaseSource("ImportTestCases")] public void import_new_file_with_better_same_quality_should_succeed(QualityTypes currentFileQuality, bool currentFileProper) { const string newFile = @"WEEDS.S03E01.DUAL.1080p.HELLYWOOD.mkv"; @@ -262,9 +267,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests .Build()) .Build(); - //Mocks - - Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs index 29161b848..68d9ddf28 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests .Returns(fi); Mocker.GetMock() - .Setup(s => s.GetDownloadTitle(It.Is(e => e.Quality == new QualityModel{ QualityType = QualityTypes.WEBDL, Proper = false }))) + .Setup(s => s.GetDownloadTitle(It.Is(e => e.Quality == new QualityModel{ Quality = QualityTypes.WEBDL, Proper = false }))) .Returns(message); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs index 49ced0e0e..6a9cb6f3e 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List { 5 }, SeasonNumber = 1, - Quality = new QualityModel { QualityType = QualityTypes.SDTV, Proper = false }, + Quality = new QualityModel { Quality = QualityTypes.SDTV, Proper = false }, Series = new Series { Title = "30 Rock", CleanTitle = Parser.NormalizeTitle("30 Rock") }, }; @@ -145,7 +145,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests var parseResult = new EpisodeParseResult { - Quality = new QualityModel { QualityType = QualityTypes.Bluray720p, Proper = false }, + Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false }, AirDate = new DateTime(2011, 12, 01), Series = new Series { Title = "The Dailyshow", CleanTitle = Parser.NormalizeTitle("The Dailyshow"), IsDaily = true }, }; @@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests var parseResult = new EpisodeParseResult { - Quality = new QualityModel { QualityType = QualityTypes.Bluray720p, Proper = false }, + Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false }, FullSeason = true, SeasonNumber = 5, Series = new Series { Title = "My Name is earl", CleanTitle = Parser.NormalizeTitle("My Name is earl") }, @@ -175,13 +175,18 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests result.Should().BeTrue(); } - [TestCase(2, new[] { 5 }, "30 Rock", QualityTypes.Bluray1080p, true, Description = "Same Series, Different Season, Episode")] - [TestCase(1, new[] { 6 }, "30 Rock", QualityTypes.Bluray1080p, true, Description = "Same series, different episodes")] - [TestCase(1, new[] { 6, 7, 8 }, "30 Rock", QualityTypes.Bluray1080p, true, Description = "Same series, different episodes")] - [TestCase(1, new[] { 6 }, "Some other show", QualityTypes.Bluray1080p, true, Description = "Different series, same season, episode")] - [TestCase(1, new[] { 5 }, "Rock", QualityTypes.Bluray1080p, true, Description = "Similar series, same season, episodes")] - [TestCase(1, new[] { 5 }, "30 Rock", QualityTypes.Bluray720p, false, Description = "Same series, higher quality")] - [TestCase(1, new[] { 5 }, "30 Rock", QualityTypes.HDTV, true, Description = "Same series, higher quality")] + public static object[] DifferentEpisodeCases = + { + new object[] { 2, new[] { 5 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same Series, Different Season, Episode + new object[] { 1, new[] { 6 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same series, different episodes + new object[] { 1, new[] { 6, 7, 8 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same series, different episodes + new object[] { 1, new[] { 6 }, "Some other show", QualityTypes.Bluray1080p, true }, //Different series, same season, episode + new object[] { 1, new[] { 5 }, "Rock", QualityTypes.Bluray1080p, true }, //Similar series, same season, episodes + new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.Bluray720p, false }, //Same series, higher quality + new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.HDTV, true } //Same series, higher quality + }; + + [Test, TestCaseSource("DifferentEpisodeCases")] public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] episodes, string title, QualityTypes qualityType, bool proper) { WithFullQueue(); @@ -191,7 +196,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new QualityModel { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { Quality = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -200,12 +205,17 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests result.Should().BeFalse(); } - [TestCase(1, new[] { 5 }, "30 Rock", QualityTypes.SDTV, false, Description = "Same Series, lower quality")] - [TestCase(1, new[] { 5 }, "30 rocK", QualityTypes.SDTV, false, Description = "Same Series, different casing")] - [TestCase(1, new[] { 5 }, "30 RocK", QualityTypes.HDTV, false, Description = "Same Series, same quality")] - [TestCase(1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false, Description = "Same Series, same quality, one different episode")] - [TestCase(1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false, Description = "Same Series, same quality, one different episode")] - [TestCase(4, new[] { 8 }, "Parks and Recreation", QualityTypes.WEBDL, false, Description = "Same Series, same quality")] + public static object[] LowerQualityCases = + { + new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.SDTV, false }, //Same Series, lower quality + new object[] { 1, new[] { 5 }, "30 rocK", QualityTypes.SDTV, false }, //Same Series, different casing + new object[] { 1, new[] { 5 }, "30 RocK", QualityTypes.HDTV, false }, //Same Series, same quality + new object[] { 1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false }, //Same Series, same quality, one different episode + new object[] { 1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV, false }, //Same Series, same quality, one different episode + new object[] { 4, new[] { 8 }, "Parks and Recreation", QualityTypes.WEBDL }, false, //Same Series, same quality + }; + + [Test, TestCaseSource("LowerQualityCases")] public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season, int[] episodes, string title, QualityTypes qualityType, bool proper) { WithFullQueue(); @@ -215,7 +225,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new QualityModel { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { Quality = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -224,10 +234,15 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests result.Should().BeTrue(); } - [TestCase(5, new[] { 13 }, "The Big Bang Theory", QualityTypes.SDTV, false, Description = "Same Series, lower quality")] - [TestCase(5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, false, Description = "Same Series, same quality")] - [TestCase(5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, true, Description = "Same Series, same quality")] - [TestCase(5, new[] { 13, 14 }, "The Big Bang Theory", QualityTypes.HDTV, false, Description = "Same Series, same quality, one diffrent episode")] + public static object[] DuplicateItemsCases = + { + new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.SDTV, false }, //Same Series, lower quality + new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, false }, //Same Series, same quality + new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV, true }, //Same Series, same quality + new object[] { 5, new[] { 13, 14 }, "The Big Bang Theory", QualityTypes.HDTV, false } //Same Series, same quality, one diffrent episode + }; + + [Test, TestCaseSource("DuplicateItemsCases")] public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] episodes, string title, QualityTypes qualityType, bool proper) { WithFullQueue(); @@ -237,7 +252,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new QualityModel { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { Quality = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -246,10 +261,15 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests result.Should().BeTrue(); } - [TestCase(3, new[] { 14, 15 }, "My Name Is Earl", QualityTypes.Bluray720p, false)] - [TestCase(3, new[] { 15 }, "My Name Is Earl", QualityTypes.DVD, false)] - [TestCase(3, new[] { 14 }, "My Name Is Earl", QualityTypes.HDTV, false)] - [TestCase(3, new[] { 15, 16 }, "My Name Is Earl", QualityTypes.SDTV, false)] + public static object[] DoubleEpisodeCases = + { + new object[] { 3, new[] { 14, 15 }, "My Name Is Earl", QualityTypes.Bluray720p, false }, + new object[] { 3, new[] { 15 }, "My Name Is Earl", QualityTypes.DVD, false }, + new object[] { 3, new[] { 14 }, "My Name Is Earl", QualityTypes.HDTV, false }, + new object[] { 3, new[] { 15, 16 }, "My Name Is Earl", QualityTypes.SDTV, false } + }; + + [Test, TestCaseSource("DoubleEpisodeCases")] public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, string title, QualityTypes qualityType, bool proper) { WithFullQueue(); @@ -259,7 +279,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List(episodes), SeasonNumber = season, - Quality = new QualityModel { QualityType = qualityType, Proper = proper }, + Quality = new QualityModel { Quality = qualityType, Proper = proper }, Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) }, }; @@ -278,7 +298,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests EpisodeTitle = "Title", EpisodeNumbers = new List { 1 }, SeasonNumber = 2, - Quality = new QualityModel { QualityType = QualityTypes.Bluray1080p, Proper = true }, + Quality = new QualityModel { Quality = QualityTypes.Bluray1080p, Proper = true }, Series = new Series { Title = "Test", CleanTitle = Parser.NormalizeTitle("Test") }, }; diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs index e59031378..5b3b938de 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadProviderFixture.cs @@ -20,6 +20,15 @@ namespace NzbDrone.Core.Test.ProviderTests [TestFixture] public class DownloadProviderFixture : CoreTest { + public static object[] SabNamingCases = + { + new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" }, + new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" }, + new object[] { 1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" }, + new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV]" }, + new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV] [Proper]" }, + new object[] { 1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, "My Series Name - 1x02-1x04 - [HDTV] [Proper]" }, + }; private void SetDownloadClient(DownloadClientType clientType) { @@ -68,7 +77,6 @@ namespace NzbDrone.Core.Test.ProviderTests .Returns(false); } - [Test] public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed() { @@ -162,8 +170,6 @@ namespace NzbDrone.Core.Test.ProviderTests .Verify(c => c.OnGrab(It.IsAny()), Times.Never()); } - - [Test] public void should_return_sab_as_active_client() { @@ -178,14 +184,8 @@ namespace NzbDrone.Core.Test.ProviderTests Mocker.Resolve().GetActiveDownloadClient().Should().BeAssignableTo(); } - - [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.CreateNew() .With(c => c.Title = "My Series Name") @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.ProviderTests EpisodeTitle = title }; - return Mocker.Resolve().GetDownloadTitle(parsResult); + Mocker.Resolve().GetDownloadTitle(parsResult).Should().Be(expected); } [TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")] diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs index d17aa670a..125225091 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.ProviderTests WithRealDb(); var fakeSeries = Builder.CreateNew().Build(); - var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).Build(); + var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build(); var fakeEpisodes = Builder.CreateListOfSize(5) .All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build(); @@ -858,7 +858,7 @@ namespace NzbDrone.Core.Test.ProviderTests WithRealDb(); var fakeSeries = Builder.CreateNew().Build(); - var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).Build(); + var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build(); var fakeEpisodes = Builder.CreateListOfSize(5) .All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build(); @@ -902,7 +902,7 @@ namespace NzbDrone.Core.Test.ProviderTests WithRealDb(); var fakeSeries = Builder.CreateNew().Build(); - var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).Build(); + var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build(); var fakeEpisodes = Builder.CreateListOfSize(5) .All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build(); @@ -1224,6 +1224,7 @@ namespace NzbDrone.Core.Test.ProviderTests var episodeFile = Builder.CreateNew() .With(c => c.EpisodeFileId = 1) + .With(c => c.Quality = QualityTypes.SDTV) .Build(); var episodes = Builder.CreateListOfSize(2) diff --git a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs index a73db927d..3375fa39c 100644 --- a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs @@ -19,7 +19,10 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); //Setup - var historyItem = Builder.CreateListOfSize(10).Build(); + var historyItem = Builder.CreateListOfSize(10) + .All() + .With(c => c.Quality = QualityTypes.SDTV) + .Build(); Db.InsertMany(historyItem); @@ -39,7 +42,15 @@ namespace NzbDrone.Core.Test.ProviderTests var episodes = Builder.CreateListOfSize(10).Build(); - var historyItems = Builder.CreateListOfSize(10).TheFirst(5).With(h => h.SeriesId = seriesOne.SeriesId).TheLast(5).With(h => h.SeriesId = seriesTwo.SeriesId).Build(); + var historyItems = Builder + .CreateListOfSize(10) + .All() + .With(c => c.Quality = QualityTypes.SDTV) + .TheFirst(5) + .With(h => h.SeriesId = seriesOne.SeriesId) + .TheLast(5) + .With(h => h.SeriesId = seriesTwo.SeriesId) + .Build(); Db.InsertMany(historyItems); @@ -65,7 +76,11 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var historyItem = Builder.CreateListOfSize(10).Build(); + var historyItem = Builder + .CreateListOfSize(10) + .All() + .With(c => c.Quality = QualityTypes.SDTV) + .Build(); Db.InsertMany(historyItem); //Act @@ -82,6 +97,8 @@ namespace NzbDrone.Core.Test.ProviderTests WithRealDb(); var historyItem = Builder.CreateListOfSize(30) + .All() + .With(c => c.Quality = QualityTypes.SDTV) .TheFirst(10).With(c => c.Date = DateTime.Now) .TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31)) .Build(); @@ -129,7 +146,7 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert result.Should().NotBeNull(); - result.QualityType.Should().Be(QualityTypes.Bluray720p); + result.Quality.Should().Be(QualityTypes.Bluray720p); result.Proper.Should().BeTrue(); } @@ -184,7 +201,7 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert result.Should().NotBeNull(); - result.QualityType.Should().Be(QualityTypes.Bluray720p); + result.Quality.Should().Be(QualityTypes.Bluray720p); result.Proper.Should().BeTrue(); } @@ -195,7 +212,7 @@ namespace NzbDrone.Core.Test.ProviderTests var episode = Builder.CreateNew().Build(); - const QualityTypes quality = QualityTypes.HDTV; + QualityTypes quality = QualityTypes.HDTV; const bool proper = true; var history = new History diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs index 1a746bd27..041bd7a76 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs @@ -12,6 +12,7 @@ using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; +using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; @@ -25,10 +26,14 @@ namespace NzbDrone.Core.Test.ProviderTests public void get_series_files() { var firstSeriesFiles = Builder.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.CreateListOfSize(10) - .All().With(s => s.SeriesId = 20).Build(); + .All() + .With(c => c.Quality = QualityTypes.SDTV) + .With(s => s.SeriesId = 20).Build(); @@ -51,12 +56,14 @@ namespace NzbDrone.Core.Test.ProviderTests { var firstSeriesFiles = Builder.CreateListOfSize(10) .All() + .With(c => c.Quality = QualityTypes.SDTV) .With(s => s.SeriesId = 12) .With(s => s.SeasonNumber = 1) .Build(); var secondSeriesFiles = Builder.CreateListOfSize(10) .All() + .With(c => c.Quality = QualityTypes.SDTV) .With(s => s.SeriesId = 12) .With(s => s.SeasonNumber = 2) .Build(); @@ -143,7 +150,11 @@ namespace NzbDrone.Core.Test.ProviderTests public void DeleteEpisodeFile() { //Setup - var episodeFiles = Builder.CreateListOfSize(10).Build(); + var episodeFiles = Builder + .CreateListOfSize(10) + .All() + .With(c => c.Quality = QualityTypes.SDTV) + .Build(); var database = TestDbHelper.GetEmptyDatabase(); @@ -180,6 +191,7 @@ namespace NzbDrone.Core.Test.ProviderTests //Setup WithRealDb(); var episodeFile = Builder.CreateNew() + .With(c => c.Quality = QualityTypes.SDTV) .With(f => f.Path = path.NormalizePath()) .Build(); diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests/CleanUpDatabaseFixture.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests/CleanUpDatabaseFixture.cs index 5ff88752e..f812bbfc1 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests/CleanUpDatabaseFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests/CleanUpDatabaseFixture.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; +using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests @@ -116,7 +117,11 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests public void DeleteOrphanedEpisodeFiles() { //Setup - var episodeFiles = Builder.CreateListOfSize(10).Build(); + var episodeFiles = Builder + .CreateListOfSize(10) + .All() + .With(e => e.Quality = QualityTypes.DVD) + .Build(); var episodes = Builder.CreateListOfSize(5).Build(); Db.InsertMany(episodes); diff --git a/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs index 480f043a5..fbd358318 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs @@ -37,6 +37,8 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var items = Builder.CreateListOfSize(10) + .All() + .With(c => c.Quality = QualityTypes.SDTV) .Build().ToList(); _searchHistory = Builder.CreateNew() @@ -77,6 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests { var items = Builder.CreateListOfSize(10) .All() + .With(c => c.Quality = QualityTypes.SDTV) .With(i => i.Id == searchHistory.Id) .Build(); @@ -97,6 +100,7 @@ namespace NzbDrone.Core.Test.ProviderTests { var items = Builder.CreateListOfSize(10) .All() + .With(c => c.Quality = QualityTypes.SDTV) .With(i => i.Id == searchHistory.Id) .Build(); diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs index 9d3b1173a..c4968880f 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests WithSuccessfulDownload(); Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.QualityType == QualityTypes.Bluray1080p))) + .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.Quality == QualityTypes.Bluray1080p))) .Returns(ReportRejectionType.None); //Act @@ -221,11 +221,11 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests WithQualityNeeded(); Mocker.GetMock() - .Setup(s => s.DownloadReport(It.Is(d => d.Quality.QualityType == QualityTypes.DVD))) + .Setup(s => s.DownloadReport(It.Is(d => d.Quality.Quality == QualityTypes.DVD))) .Returns(false); Mocker.GetMock() - .Setup(s => s.DownloadReport(It.Is(d => d.Quality.QualityType == QualityTypes.SDTV))) + .Setup(s => s.DownloadReport(It.Is(d => d.Quality.Quality == QualityTypes.SDTV))) .Returns(true); //Act diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs index 5320eb748..b14873e11 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests WithSuccessfulDownload(); Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.QualityType == QualityTypes.Bluray1080p))) + .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.Quality == QualityTypes.Bluray1080p))) .Returns(ReportRejectionType.None); //Act @@ -311,11 +311,11 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests WithQualityNeeded(); Mocker.GetMock() - .Setup(s => s.DownloadReport(It.Is(d => d.Quality.QualityType == QualityTypes.DVD))) + .Setup(s => s.DownloadReport(It.Is(d => d.Quality.Quality == QualityTypes.DVD))) .Returns(false); Mocker.GetMock() - .Setup(s => s.DownloadReport(It.Is(d => d.Quality.QualityType == QualityTypes.SDTV))) + .Setup(s => s.DownloadReport(It.Is(d => d.Quality.Quality == QualityTypes.SDTV))) .Returns(true); //Act @@ -349,7 +349,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests WithSuccessfulDownload(); Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.QualityType == QualityTypes.Bluray1080p))) + .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.Quality == QualityTypes.Bluray1080p))) .Returns(ReportRejectionType.None); //Act diff --git a/NzbDrone.Core.Test/QualityTest.cs b/NzbDrone.Core.Test/QualityTest.cs index c55747182..05f2136af 100644 --- a/NzbDrone.Core.Test/QualityTest.cs +++ b/NzbDrone.Core.Test/QualityTest.cs @@ -75,7 +75,6 @@ namespace NzbDrone.Core.Test (first == second).Should().BeFalse(); } - [Test] public void not_equal_operand() { diff --git a/NzbDrone.Core.Test/QualityTypesTest.cs b/NzbDrone.Core.Test/QualityTypesTest.cs new file mode 100644 index 000000000..6208bef18 --- /dev/null +++ b/NzbDrone.Core.Test/QualityTypesTest.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.IO; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Model; +using NzbDrone.Core.Repository.Quality; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test +{ + [TestFixture] + // ReSharper disable InconsistentNaming + public class QualityTypesTest : CoreTest + { + public static object[] FromIntCases = + { + new object[] {1, QualityTypes.SDTV}, + new object[] {2, QualityTypes.DVD}, + new object[] {4, QualityTypes.HDTV}, + new object[] {5, QualityTypes.WEBDL}, + new object[] {6, QualityTypes.Bluray720p}, + new object[] {7, QualityTypes.Bluray1080p} + }; + + public static object[] ToIntCases = + { + new object[] {QualityTypes.SDTV, 1}, + new object[] {QualityTypes.DVD, 2}, + new object[] {QualityTypes.HDTV, 4}, + new object[] {QualityTypes.WEBDL, 5}, + new object[] {QualityTypes.Bluray720p, 6}, + new object[] {QualityTypes.Bluray1080p, 7} + }; + + [Test, TestCaseSource("FromIntCases")] + public void should_be_able_to_convert_int_to_qualityTypes(int source, QualityTypes expected) + { + var quality = (QualityTypes)source; + quality.Should().Be(expected); + } + + [Test, TestCaseSource("ToIntCases")] + public void should_be_able_to_convert_qualityTypes_to_int(QualityTypes source, int expected) + { + var i = (int)source; + i.Should().Be(expected); + } + + + [Test] + public void Icomparer_greater_test() + { + var first = QualityTypes.DVD; + var second = QualityTypes.Bluray1080p; + + second.Should().BeGreaterThan(first); + } + + [Test] + public void Icomparer_lesser() + { + var first = QualityTypes.DVD; + var second = QualityTypes.Bluray1080p; + + first.Should().BeLessThan(second); + } + + [Test] + public void equal_operand() + { + var first = QualityTypes.Bluray1080p; + var second = QualityTypes.Bluray1080p; + + (first == second).Should().BeTrue(); + (first >= second).Should().BeTrue(); + (first <= second).Should().BeTrue(); + } + + [Test] + public void equal_operand_false() + { + var first = QualityTypes.Bluray1080p; + var second = QualityTypes.Unknown; + + (first == second).Should().BeFalse(); + } + + [Test] + public void not_equal_operand() + { + var first = QualityTypes.Bluray1080p; + var second = QualityTypes.Bluray1080p; + + (first != second).Should().BeFalse(); + } + + [Test] + public void not_equal_operand_false() + { + var first = QualityTypes.Bluray1080p; + var second = QualityTypes.Unknown; + + (first != second).Should().BeTrue(); + } + + [Test] + public void greater_operand() + { + var first = QualityTypes.DVD; + var second = QualityTypes.Bluray1080p; + + (first < second).Should().BeTrue(); + (first <= second).Should().BeTrue(); + } + + [Test] + public void lesser_operand() + { + var first = QualityTypes.DVD; + var second = QualityTypes.Bluray1080p; + + (second > first).Should().BeTrue(); + (second >= first).Should().BeTrue(); + } + } +} diff --git a/NzbDrone.Core/Datastore/CustomeMapper.cs b/NzbDrone.Core/Datastore/CustomeMapper.cs index e31a7625b..bc32a72ba 100644 --- a/NzbDrone.Core/Datastore/CustomeMapper.cs +++ b/NzbDrone.Core/Datastore/CustomeMapper.cs @@ -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 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 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" then this will return just "int" @@ -31,6 +45,17 @@ namespace NzbDrone.Core.Datastore }; } + if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType == typeof(QualityTypes)) + { + return delegate(object s) + { + int value; + Int32.TryParse(s.ToString(), out value); + var quality = (QualityTypes)value; + return quality; + }; + } + return base.GetFromDbConverter(destinationType, sourceType); } diff --git a/NzbDrone.Core/Model/QualityModel.cs b/NzbDrone.Core/Model/QualityModel.cs index ed545ae98..6987b2177 100644 --- a/NzbDrone.Core/Model/QualityModel.cs +++ b/NzbDrone.Core/Model/QualityModel.cs @@ -5,7 +5,7 @@ namespace NzbDrone.Core.Model { public class QualityModel : IComparable { - public QualityTypes QualityType { get; set; } + public QualityTypes Quality { get; set; } public Boolean Proper { get; set; } @@ -13,19 +13,19 @@ namespace NzbDrone.Core.Model public QualityModel(QualityTypes quality, Boolean proper) { - QualityType = quality; + Quality = quality; Proper = proper; } public int CompareTo(QualityModel other) { - if (other.QualityType > QualityType) + if (other.Quality > Quality) return -1; - if (other.QualityType < QualityType) + if (other.Quality < Quality) return 1; - if (other.QualityType == QualityType && other.Proper == Proper) + if (other.Quality == Quality && other.Proper == Proper) return 0; if (Proper && !other.Proper) @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Model public static bool operator <(QualityModel x, QualityModel y) { - return x.CompareTo(y) < 1; + return x.CompareTo(y) < 0; } public static bool operator <=(QualityModel x, QualityModel y) @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Model public override string ToString() { - string result = QualityType.ToString(); + string result = Quality.ToString(); if (Proper) { result += " [proper]"; @@ -92,7 +92,7 @@ namespace NzbDrone.Core.Model { int hash = 17; hash = hash * 23 + Proper.GetHashCode(); - hash = hash * 23 + QualityType.GetHashCode(); + hash = hash * 23 + Quality.GetHashCode(); return hash; } } @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Model { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return Equals(other.QualityType, QualityType) && other.Proper.Equals(Proper); + return Equals(other.Quality, Quality) && other.Proper.Equals(Proper); } public override bool Equals(object obj) diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index ec13af4a1..ef19116ad 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -273,7 +273,7 @@ - + @@ -330,6 +330,7 @@ + @@ -541,7 +542,6 @@ - diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index e087af92f..e16db0894 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -251,12 +251,12 @@ namespace NzbDrone.Core name = name.Trim(); var normalizedName = NormalizeTitle(name); - var result = new QualityModel { QualityType = QualityTypes.Unknown }; + var result = new QualityModel { Quality = QualityTypes.Unknown }; result.Proper = (normalizedName.Contains("proper") || normalizedName.Contains("repack")); if (normalizedName.Contains("dvd") || normalizedName.Contains("bdrip") || normalizedName.Contains("brrip")) { - result.QualityType = QualityTypes.DVD; + result.Quality = QualityTypes.DVD; return result; } @@ -264,11 +264,11 @@ namespace NzbDrone.Core { if (normalizedName.Contains("bluray")) { - result.QualityType = QualityTypes.DVD; + result.Quality = QualityTypes.DVD; return result; } - result.QualityType = QualityTypes.SDTV; + result.Quality = QualityTypes.SDTV; return result; } @@ -276,32 +276,32 @@ namespace NzbDrone.Core { if (normalizedName.Contains("720p")) { - result.QualityType = QualityTypes.Bluray720p; + result.Quality = QualityTypes.Bluray720p; return result; } if (normalizedName.Contains("1080p")) { - result.QualityType = QualityTypes.Bluray1080p; + result.Quality = QualityTypes.Bluray1080p; return result; } - result.QualityType = QualityTypes.Bluray720p; + result.Quality = QualityTypes.Bluray720p; return result; } if (normalizedName.Contains("webdl")) { - result.QualityType = QualityTypes.WEBDL; + result.Quality = QualityTypes.WEBDL; return result; } if (normalizedName.Contains("x264") || normalizedName.Contains("h264") || normalizedName.Contains("720p")) { - result.QualityType = QualityTypes.HDTV; + result.Quality = QualityTypes.HDTV; return result; } //Based on extension - if (result.QualityType == QualityTypes.Unknown) + if (result.Quality == QualityTypes.Unknown) { try { @@ -322,13 +322,13 @@ namespace NzbDrone.Core case ".ogm": case ".strm": { - result.QualityType = QualityTypes.SDTV; + result.Quality = QualityTypes.SDTV; break; } case ".mkv": case ".ts": { - result.QualityType = QualityTypes.HDTV; + result.Quality = QualityTypes.HDTV; break; } } @@ -342,15 +342,15 @@ namespace NzbDrone.Core if (name.Contains("[HDTV]")) { - result.QualityType = QualityTypes.HDTV; + result.Quality = QualityTypes.HDTV; return result; } if ((normalizedName.Contains("sdtv") || normalizedName.Contains("pdtv") || - (result.QualityType == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) && + (result.Quality == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) && !normalizedName.Contains("mpeg")) { - result.QualityType = QualityTypes.SDTV; + result.Quality = QualityTypes.SDTV; return result; } diff --git a/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs index 8777ef153..1ff28cf57 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine public virtual bool IsSatisfiedBy(EpisodeParseResult subject) { logger.Trace("Beginning size check for: {0}", subject); - var qualityType = _qualityTypeProvider.Get((int)subject.Quality.QualityType); + var qualityType = _qualityTypeProvider.Get((int)subject.Quality.Quality); //Need to determine if this is a 30 or 60 minute episode //Is it a multi-episode release? diff --git a/NzbDrone.Core/Providers/DecisionEngine/QualityAllowedByProfileSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/QualityAllowedByProfileSpecification.cs index db32aa20a..a67ba9e00 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/QualityAllowedByProfileSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/QualityAllowedByProfileSpecification.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine public virtual bool IsSatisfiedBy(EpisodeParseResult subject) { logger.Trace("Checking if report meets quality requirements. {0}", subject.Quality); - if (!subject.Series.QualityProfile.Allowed.Contains(subject.Quality.QualityType)) + if (!subject.Series.QualityProfile.Allowed.Contains(subject.Quality.Quality)) { logger.Trace("Quality {0} rejected by Series' quality profile", subject.Quality); return false; diff --git a/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs index 594626205..b7e55fae0 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/QualityUpgradeSpecification.cs @@ -17,13 +17,13 @@ namespace NzbDrone.Core.Providers.DecisionEngine return false; } - if (currentQuality.QualityType == newQuality.QualityType && newQuality.Proper) + if (currentQuality.Quality == newQuality.Quality && newQuality.Proper) { logger.Trace("Upgrading existing item to proper."); return true; } - if (currentQuality.QualityType >= cutOff) + if (currentQuality.Quality >= cutOff) { logger.Trace("Existing item meets cut-off. skipping."); return false; diff --git a/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs index 58711f6bc..0f080364e 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine foreach (var file in _episodeProvider.GetEpisodesByParseResult(subject).Select(c => c.EpisodeFile).Where(c => c != null)) { logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper); - if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { QualityType = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff)) + if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { Quality = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff)) return false; } diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index e6ae304d8..943b052ee 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -153,7 +153,7 @@ namespace NzbDrone.Core.Providers episodeFile.SeriesId = series.SeriesId; episodeFile.Path = filePath.NormalizePath(); episodeFile.Size = size; - episodeFile.Quality = parseResult.Quality.QualityType; + episodeFile.Quality = parseResult.Quality.Quality; episodeFile.Proper = parseResult.Quality.Proper; episodeFile.SeasonNumber = parseResult.SeasonNumber; episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath()); @@ -202,7 +202,7 @@ namespace NzbDrone.Core.Providers var parseResult = Parser.ParsePath(episodeFile.Path); parseResult.Series = series; - parseResult.Quality = new QualityModel{ QualityType = episodeFile.Quality, Proper = episodeFile.Proper }; + parseResult.Quality = new QualityModel{ Quality = episodeFile.Quality, Proper = episodeFile.Proper }; var message = _downloadProvider.GetDownloadTitle(parseResult); diff --git a/NzbDrone.Core/Providers/DownloadProvider.cs b/NzbDrone.Core/Providers/DownloadProvider.cs index 05b9753ad..fb7a1366f 100644 --- a/NzbDrone.Core/Providers/DownloadProvider.cs +++ b/NzbDrone.Core/Providers/DownloadProvider.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Providers Date = DateTime.Now, Indexer = parseResult.Indexer, IsProper = parseResult.Quality.Proper, - Quality = parseResult.Quality.QualityType, + Quality = parseResult.Quality.Quality, NzbTitle = parseResult.OriginalString, EpisodeId = episode.EpisodeId, SeriesId = episode.SeriesId, @@ -107,7 +107,7 @@ namespace NzbDrone.Core.Providers if (parseResult.FullSeason) { var seasonResult = String.Format("{0} - Season {1} [{2}]", seriesTitle, - parseResult.SeasonNumber, parseResult.Quality.QualityType); + parseResult.SeasonNumber, parseResult.Quality.Quality); if (parseResult.Quality.Proper) seasonResult += " [Proper]"; @@ -118,7 +118,7 @@ namespace NzbDrone.Core.Providers if (parseResult.Series.IsDaily) { var dailyResult = String.Format("{0} - {1:yyyy-MM-dd} - {2} [{3}]", seriesTitle, - parseResult.AirDate, parseResult.EpisodeTitle, parseResult.Quality.QualityType); + parseResult.AirDate, parseResult.EpisodeTitle, parseResult.Quality.Quality); if (parseResult.Quality.Proper) dailyResult += " [Proper]"; @@ -137,7 +137,7 @@ namespace NzbDrone.Core.Providers var epNumberString = String.Join("-", episodeString); - var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, parseResult.EpisodeTitle, parseResult.Quality.QualityType); + var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, parseResult.EpisodeTitle, parseResult.Quality.Quality); if (parseResult.Quality.Proper) { diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index 8aa86a491..3042ec12b 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -275,7 +275,7 @@ namespace NzbDrone.Core.Providers ReportTitle = episodeParseResult.OriginalString, NzbUrl = episodeParseResult.NzbUrl, Indexer = episodeParseResult.Indexer, - Quality = episodeParseResult.Quality.QualityType, + Quality = episodeParseResult.Quality.Quality, Proper = episodeParseResult.Quality.Proper, Size = episodeParseResult.Size, Age = episodeParseResult.Age, @@ -369,7 +369,7 @@ namespace NzbDrone.Core.Providers ReportTitle = episodeParseResult.OriginalString, NzbUrl = episodeParseResult.NzbUrl, Indexer = episodeParseResult.Indexer, - Quality = episodeParseResult.Quality.QualityType, + Quality = episodeParseResult.Quality.Quality, Proper = episodeParseResult.Quality.Proper, Size = episodeParseResult.Size, Age = episodeParseResult.Age, diff --git a/NzbDrone.Core/Providers/SignalRProvider.cs b/NzbDrone.Core/Providers/SignalRProvider.cs index 01769116d..671c8d058 100644 --- a/NzbDrone.Core/Providers/SignalRProvider.cs +++ b/NzbDrone.Core/Providers/SignalRProvider.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Providers { EpisodeId = episodeId, EpisodeStatus = episodeStatus.ToString(), - Quality = (quality == null ? String.Empty : quality.QualityType.ToString()) + Quality = (quality == null ? String.Empty : quality.Quality.ToString()) }); var test = 0; } diff --git a/NzbDrone.Core/Repository/EpisodeFile.cs b/NzbDrone.Core/Repository/EpisodeFile.cs index b4d928d60..c6b137c47 100644 --- a/NzbDrone.Core/Repository/EpisodeFile.cs +++ b/NzbDrone.Core/Repository/EpisodeFile.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Repository } set { - Quality = value.QualityType; + Quality = value.Quality; Proper = value.Proper; } } diff --git a/NzbDrone.Core/Repository/Quality/QualityProfile.cs b/NzbDrone.Core/Repository/Quality/QualityProfile.cs index f11f8e640..e21a93292 100644 --- a/NzbDrone.Core/Repository/Quality/QualityProfile.cs +++ b/NzbDrone.Core/Repository/Quality/QualityProfile.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Repository.Quality foreach (var q in Allowed) { - result += (int)q + "|"; + result += q.Id + "|"; } return result.Trim('|'); } @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Repository.Quality Allowed = new List(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))); } } } diff --git a/NzbDrone.Core/Repository/Quality/QualityTypes.cs b/NzbDrone.Core/Repository/Quality/QualityTypes.cs index c260033a1..161461477 100644 --- a/NzbDrone.Core/Repository/Quality/QualityTypes.cs +++ b/NzbDrone.Core/Repository/Quality/QualityTypes.cs @@ -1,44 +1,124 @@ +using System; + namespace NzbDrone.Core.Repository.Quality { - // ReSharper disable InconsistentNaming - /// - /// Represents Video Quality - /// - public enum QualityTypes + public class QualityTypes : IComparable { - /// - /// Quality is unknown - /// - Unknown = 0, + public int Id { get; set; } + public string Name { get; set; } + public int Weight { get; set; } - /// - /// SD File (Source could be HD) - /// - SDTV = 1, + public int CompareTo(QualityTypes other) + { + if (other.Weight > Weight) + return -1; - /// - /// SD File (DVD Source) - /// - DVD = 2, + if (other.Weight < Weight) + return 1; - /// - /// HD File (HDTV Source) - /// - HDTV = 4, + if (other.Weight == Weight) + return 0; - /// - /// HD File (Online Source) - /// - WEBDL = 5, + return 0; + } - /// - /// HD File (720p Blu-ray Source) - /// - Bluray720p = 6, + public static bool operator !=(QualityTypes x, QualityTypes y) + { + return !(x == y); + } - /// - /// HD File (1080p Blu-ray Source) - /// - Bluray1080p = 7, + public static bool operator ==(QualityTypes x, QualityTypes y) + { + var xObj = (Object)x; + var yObj = (object)y; + + if (xObj == null || yObj == null) + { + return xObj == yObj; + } + + return x.CompareTo(y) == 0; + } + + public static bool operator >(QualityTypes x, QualityTypes y) + { + return x.CompareTo(y) > 0; + } + + public static bool operator <(QualityTypes x, QualityTypes y) + { + return x.CompareTo(y) < 0; + } + + public static bool operator <=(QualityTypes x, QualityTypes y) + { + return x.CompareTo(y) <= 0; + } + + public static bool operator >=(QualityTypes x, QualityTypes y) + { + return x.CompareTo(y) >= 0; + } + + public override string ToString() + { + return Name; + } + + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 23 + Weight.GetHashCode(); + return hash; + } + } + + public bool Equals(QualityTypes other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(other.Weight, Weight); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != typeof (QualityTypes)) return false; + return Equals((QualityTypes) obj); + } + + public static QualityTypes Unknown = new QualityTypes { Id = 0, Name = "Unknown", Weight = 0 }; + public static QualityTypes SDTV = new QualityTypes {Id = 1, Name = "SDTV", Weight = 1}; + public static QualityTypes DVD = new QualityTypes { Id = 2, Name = "DVD", Weight = 2 }; + public static QualityTypes HDTV = new QualityTypes { Id = 4, Name = "HDTV", Weight = 4 }; + public static QualityTypes WEBDL = new QualityTypes { Id = 5, Name = "WEBDL", Weight = 5 }; + public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 6 }; + public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 7 }; + + public static QualityTypes FindById(int id) + { + if (id == 0) return Unknown; + if (id == 1) return SDTV; + if (id == 2) return DVD; + if (id == 4) return HDTV; + if (id == 5) return WEBDL; + if (id == 6) return Bluray720p; + if (id == 7) return Bluray1080p; + + throw new ArgumentException("ID does not match a known quality", "id"); + } + + public static explicit operator QualityTypes(int id) + { + return FindById(id); + } + + public static explicit operator int(QualityTypes quality) + { + return quality.Id; + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs b/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs index 41ad06665..0a5b0cfb9 100644 --- a/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs +++ b/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Repository.Search public string NzbInfoUrl { get; set; } public bool Success { get; set; } public ReportRejectionType SearchError { get; set; } - public QualityTypes Quality { get; set; } + public Quality.QualityTypes Quality { get; set; } public bool Proper { get; set; } public int Age { get; set; } public LanguageType Language { get; set; } diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 79ba45cc7..7971efc38 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -16,6 +16,7 @@ using NzbDrone.Core.Repository; using NzbDrone.Core.Repository.Quality; using NzbDrone.Web.Filters; using NzbDrone.Web.Models; +using QualityModel = NzbDrone.Web.Models.QualityModel; namespace NzbDrone.Web.Controllers { From 41f70ce7cac550ce9e4230b34dcaf919d08e9138 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 13 Oct 2012 17:54:46 -0700 Subject: [PATCH 3/8] Fixed broken tests --- .../ProviderTests/SeriesProviderTest.cs | 87 +++++++++++++------ NzbDrone.Core.Test/QualityProfileTest.cs | 2 +- 2 files changed, 62 insertions(+), 27 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs index 2d765676e..c55079e7c 100644 --- a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs @@ -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 _qualityProfiles; + + [SetUp] + public void Setup() + { + _qualityProfiles = Builder + .CreateListOfSize(2) + .All() + .With(p => p.Cutoff = QualityTypes.DVD) + .With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }) + .Build(); + } + [TestCase(true)] [TestCase(false)] public void Add_new_series(bool useSeasonFolder) @@ -25,7 +39,12 @@ namespace NzbDrone.Core.Test.ProviderTests Mocker.GetMock() .Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder); - var fakeProfiles = Builder.CreateListOfSize(2).Build(); + var fakeProfiles = Builder + .CreateListOfSize(2) + .All() + .With(p => p.Cutoff = QualityTypes.DVD) + .With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }) + .Build(); Db.InsertMany(fakeProfiles); @@ -96,7 +115,12 @@ namespace NzbDrone.Core.Test.ProviderTests .With(c => c.EpisodeFileCount = 0) .With(c => c.SeasonCount = 0) .Build(); - var fakeQuality = Builder.CreateNew().Build(); + + var fakeQuality = Builder + .CreateNew() + .With(p => p.Cutoff = QualityTypes.DVD) + .With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }) + .Build(); Db.Insert(fakeSeries); Db.Insert(fakeQuality); @@ -121,7 +145,12 @@ namespace NzbDrone.Core.Test.ProviderTests .With(c => c.QualityProfileId = 1) .With(c => c.CleanTitle = "laworder") .Build(); - var fakeQuality = Builder.CreateNew().Build(); + + var fakeQuality = Builder + .CreateNew() + .With(p => p.Cutoff = QualityTypes.DVD) + .With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }) + .Build(); var id = Db.Insert(fakeSeries); Db.Insert(fakeQuality); @@ -168,6 +197,8 @@ namespace NzbDrone.Core.Test.ProviderTests var fakeQuality = Builder.CreateNew() .With(c => c.QualityProfileId = fakeSeries.QualityProfileId) + .With(p => p.Cutoff = QualityTypes.DVD) + .With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }) .Build(); Db.Insert(fakeSeries); @@ -197,7 +228,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(c => c.SeriesId = 11) .Build()); - Db.InsertMany(Builder.CreateListOfSize(3).Build()); + Db.InsertMany(Builder.CreateListOfSize(3) + .All() + .With(p => p.Cutoff = QualityTypes.DVD) + .With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }) + .Build()); //Act, Assert var provider = Mocker.Resolve(); @@ -211,7 +246,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(10) .All().With(e => e.SeriesId = fakeSeries.SeriesId) @@ -242,7 +277,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.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 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(10) .All() @@ -293,7 +328,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(10) .All() @@ -324,7 +359,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(5) .All() @@ -360,7 +395,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.SeriesId = 1) @@ -391,7 +426,7 @@ namespace NzbDrone.Core.Test.ProviderTests .TheFirst(1) .With(c => c.Path = path) .Build(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); Db.InsertMany(fakeSeries); Db.Insert(fakeQuality); @@ -420,7 +455,7 @@ namespace NzbDrone.Core.Test.ProviderTests .TheFirst(1) .With(c => c.Path = path) .Build(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); Db.InsertMany(fakeSeries); Db.Insert(fakeQuality); @@ -449,7 +484,7 @@ namespace NzbDrone.Core.Test.ProviderTests .TheFirst(1) .With(c => c.Path = path) .Build(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); Db.InsertMany(fakeSeries); Db.Insert(fakeQuality); @@ -478,7 +513,7 @@ namespace NzbDrone.Core.Test.ProviderTests .TheFirst(1) .With(c => c.Path = path) .Build(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); Db.InsertMany(fakeSeries); Db.Insert(fakeQuality); @@ -499,7 +534,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(2) .All() @@ -528,7 +563,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(2) .All() @@ -557,7 +592,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(2) .All() @@ -584,7 +619,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(2) .All() @@ -613,7 +648,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(2) .All() @@ -643,7 +678,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(10) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) @@ -664,7 +699,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(10) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) @@ -685,7 +720,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(10) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) @@ -706,7 +741,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(10) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) @@ -727,7 +762,7 @@ namespace NzbDrone.Core.Test.ProviderTests { WithRealDb(); - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(10) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) @@ -753,7 +788,7 @@ namespace NzbDrone.Core.Test.ProviderTests var newMonitored = false; var newSeasonFolder = false; - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(1) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) @@ -790,7 +825,7 @@ namespace NzbDrone.Core.Test.ProviderTests var monitored = true; var seasonFolder = true; - var fakeQuality = Builder.CreateNew().Build(); + var fakeQuality = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); var fakeSeries = Builder.CreateListOfSize(2) .All() .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index 76f5066d9..1214382e4 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -155,7 +155,7 @@ namespace NzbDrone.Core.Test var db = TestDbHelper.GetEmptyDatabase(); Mocker.SetConstant(db); - var fakeProfile = Builder.CreateNew().Build(); + var fakeProfile = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); //Act Mocker.Resolve().Add(fakeProfile); From 2a1bb8989f33e354b847b31063a34b90da34fad2 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Oct 2012 10:10:23 -0700 Subject: [PATCH 4/8] Fixed Series Details --- .../Repository/Quality/QualityTypes.cs | 29 ++++++++++++++----- NzbDrone.Web/Controllers/SeriesController.cs | 3 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/NzbDrone.Core/Repository/Quality/QualityTypes.cs b/NzbDrone.Core/Repository/Quality/QualityTypes.cs index 161461477..6170adc66 100644 --- a/NzbDrone.Core/Repository/Quality/QualityTypes.cs +++ b/NzbDrone.Core/Repository/Quality/QualityTypes.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; namespace NzbDrone.Core.Repository.Quality { @@ -98,17 +100,28 @@ namespace NzbDrone.Core.Repository.Quality public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 6 }; public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 7 }; + public static List All() + { + return new List + { + Unknown, + SDTV, + DVD, + HDTV, + WEBDL, + Bluray720p, + Bluray1080p + }; + } + public static QualityTypes FindById(int id) { - if (id == 0) return Unknown; - if (id == 1) return SDTV; - if (id == 2) return DVD; - if (id == 4) return HDTV; - if (id == 5) return WEBDL; - if (id == 6) return Bluray720p; - if (id == 7) return Bluray1080p; + var quality = All().SingleOrDefault(q => q.Id == id); - throw new ArgumentException("ID does not match a known quality", "id"); + if (quality == null) + throw new ArgumentException("ID does not match a known quality", "id"); + + return quality; } public static explicit operator QualityTypes(int id) diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 9987eeec7..6fdf92ed7 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -136,8 +136,7 @@ namespace NzbDrone.Web.Controllers }).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"); From 5f217f572087ed83c4db0eb3e1df708def8f10db Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Oct 2012 16:09:07 -0700 Subject: [PATCH 5/8] Fixed quality settings --- NzbDrone.Web/Controllers/SettingsController.cs | 15 +++++++++++---- NzbDrone.Web/Models/QualityProfileModel.cs | 8 +++++++- NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js | 8 +++----- .../Views/Settings/QualityProfileItem.cshtml | 14 +++++++------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 7971efc38..d01c41593 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -127,7 +127,7 @@ namespace NzbDrone.Web.Controllers 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"); @@ -272,7 +272,7 @@ namespace NzbDrone.Web.Controllers return GetQualityProfileView(qualityProfile); } - public PartialViewResult GetQualityProfileView(QualityProfile profile) + public PartialViewResult GetQualityProfileView(QualityProfile profile) { var model = new QualityProfileModel(); model.QualityProfileId = profile.QualityProfileId; @@ -284,7 +284,14 @@ namespace NzbDrone.Web.Controllers model.Webdl = profile.Allowed.Contains(QualityTypes.WEBDL); 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.WebdlId = QualityTypes.WEBDL.Id; + model.Bluray720pId = QualityTypes.Bluray720p.Id; + model.Bluray1080pId = QualityTypes.Bluray1080p.Id; return PartialView("QualityProfileItem", model); } @@ -473,7 +480,7 @@ namespace NzbDrone.Web.Controllers 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(); diff --git a/NzbDrone.Web/Models/QualityProfileModel.cs b/NzbDrone.Web/Models/QualityProfileModel.cs index 0d7db88b2..4b70bee07 100644 --- a/NzbDrone.Web/Models/QualityProfileModel.cs +++ b/NzbDrone.Web/Models/QualityProfileModel.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Web.Models [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 Allowed { get; set; } @@ -26,20 +26,26 @@ namespace NzbDrone.Web.Models //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; } + public int WebdlId { 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; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js b/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js index c222a2e4a..869ea62e9 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js +++ b/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js @@ -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')) { - $('').appendTo(cutoff); + $('').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(); } }); diff --git a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml index c857da0dc..dee11f013 100644 --- a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml +++ b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml @@ -20,20 +20,20 @@ @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))
- @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.CheckBoxFor(m => m.Webdl, new { @class = "quality-selectee", data_quality_id = Model.WebdlId }) @Html.LabelFor(m => m.Webdl) - @Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee", data_quality_id = Model.Bluray720p }) @Html.LabelFor(m => m.Bluray720p) - @Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee", data_quality_id = Model.Bluray1080pId }) @Html.LabelFor(m => m.Bluray1080p)
@Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" }) From 2e74a6ff0525f145919b3a46b263e18ffa8b8442 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Oct 2012 17:50:01 -0700 Subject: [PATCH 6/8] Remove AJAX tabs for settings pages --- NzbDrone.Web/Content/QualitySettings.css | 16 +++-- NzbDrone.Web/Content/Settings.css | 39 ++++++++++- .../Controllers/SettingsController.cs | 57 +++++++-------- NzbDrone.Web/Helpers/IsCurrentActionHelper.cs | 35 ++++++++-- NzbDrone.Web/NzbDrone.Web.csproj | 1 + .../Views/Settings/DownloadClient.cshtml | 6 +- NzbDrone.Web/Views/Settings/Index.cshtml | 34 --------- NzbDrone.Web/Views/Settings/Indexers.cshtml | 11 ++- NzbDrone.Web/Views/Settings/Misc.cshtml | 5 +- NzbDrone.Web/Views/Settings/Naming.cshtml | 15 ++-- .../Views/Settings/Notifications.cshtml | 70 +++++++++++-------- NzbDrone.Web/Views/Settings/Quality.cshtml | 43 +++++++----- NzbDrone.Web/Views/Settings/System.cshtml | 53 +++++++------- .../Views/Settings/_SettingsLayout.cshtml | 27 +++++++ NzbDrone.Web/Views/Shared/_Layout.cshtml | 12 ++-- 15 files changed, 264 insertions(+), 160 deletions(-) delete mode 100644 NzbDrone.Web/Views/Settings/Index.cshtml create mode 100644 NzbDrone.Web/Views/Settings/_SettingsLayout.cshtml diff --git a/NzbDrone.Web/Content/QualitySettings.css b/NzbDrone.Web/Content/QualitySettings.css index 6220c1381..74f08b603 100644 --- a/NzbDrone.Web/Content/QualitySettings.css +++ b/NzbDrone.Web/Content/QualitySettings.css @@ -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; } \ No newline at end of file diff --git a/NzbDrone.Web/Content/Settings.css b/NzbDrone.Web/Content/Settings.css index 59d5d25ea..24cf5e894 100644 --- a/NzbDrone.Web/Content/Settings.css +++ b/NzbDrone.Web/Content/Settings.css @@ -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; - } \ No newline at end of file + 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; +} \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index d01c41593..2bc01dc2a 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -23,7 +23,6 @@ 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; @@ -36,6 +35,8 @@ namespace NzbDrone.Web.Controllers 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, @@ -59,7 +60,33 @@ namespace NzbDrone.Web.Controllers 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() @@ -200,32 +227,6 @@ namespace NzbDrone.Web.Controllers 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; diff --git a/NzbDrone.Web/Helpers/IsCurrentActionHelper.cs b/NzbDrone.Web/Helpers/IsCurrentActionHelper.cs index 1681d169f..d68f8c19d 100644 --- a/NzbDrone.Web/Helpers/IsCurrentActionHelper.cs +++ b/NzbDrone.Web/Helpers/IsCurrentActionHelper.cs @@ -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 @@ namespace NzbDrone.Web.Helpers 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 = "
  • "; } @@ -33,5 +44,21 @@ namespace NzbDrone.Web.Helpers return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"
  • "; } + + public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName, string controllerName) + { + string result; + + if (IsCurrentAction(helper, actionName, controllerName)) + { + result = "
  • "; + } + else + { + result = "
  • "; + } + + return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"
  • "; + } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 0bb0c2722..f41b5d750 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -412,6 +412,7 @@ +
    diff --git a/NzbDrone.Web/Views/Settings/DownloadClient.cshtml b/NzbDrone.Web/Views/Settings/DownloadClient.cshtml index ad721041d..6c7581ccb 100644 --- a/NzbDrone.Web/Views/Settings/DownloadClient.cshtml +++ b/NzbDrone.Web/Views/Settings/DownloadClient.cshtml @@ -1,6 +1,10 @@ @using NzbDrone.Web.Helpers; @model NzbDrone.Web.Models.DownloadClientSettingsModel -@{ Layout = null; } + +@{ + Layout = "_SettingsLayout.cshtml"; +} + +
    @Html.CheckBox("nzbMatrixStatus", @Model.NzbMatrixEnabled, new { @class = "indexerStatusButton" }) @@ -177,7 +181,9 @@ }
    - +} diff --git a/NzbDrone.Web/Views/Settings/Misc.cshtml b/NzbDrone.Web/Views/Settings/Misc.cshtml index 70faeb8a1..fbc82091c 100644 --- a/NzbDrone.Web/Views/Settings/Misc.cshtml +++ b/NzbDrone.Web/Views/Settings/Misc.cshtml @@ -1,6 +1,9 @@ @using NzbDrone.Web.Helpers @model NzbDrone.Web.Models.MiscSettingsModel -@{ Layout = null; } + +@{ + Layout = "_SettingsLayout.cshtml"; +}
    Enabling Backlog Searching can use lots of bandwidth and is not recommended for users with block Usenet accounts or bandwidth restrictions. diff --git a/NzbDrone.Web/Views/Settings/Naming.cshtml b/NzbDrone.Web/Views/Settings/Naming.cshtml index d3438b932..f2c1b2620 100644 --- a/NzbDrone.Web/Views/Settings/Naming.cshtml +++ b/NzbDrone.Web/Views/Settings/Naming.cshtml @@ -1,7 +1,6 @@ -@using NzbDrone.Web.Helpers -@model NzbDrone.Web.Models.EpisodeNamingModel +@model NzbDrone.Web.Models.EpisodeNamingModel @{ - Layout = null; + Layout = "_SettingsLayout.cshtml"; }