From 40a959a3091d95b0f79f856c7391ef24667f5003 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 7 Mar 2013 12:45:36 +0900 Subject: [PATCH] more search cleanup. --- .../AllowedDownloadSpecificationFixture.cs | 90 ++++++++++++++----- .../IndexerDailyEpisodeSearchFixture.cs} | 28 +++--- .../IndexerDailyEpisodeSearch_EpisodeMatch.cs | 37 ++++++++ .../IndexerEpisodeSearchFixture.cs} | 63 +++++-------- .../IndexerEpisodeSearch_EpisodeMatch.cs} | 12 +-- .../GetSearchTitleFixture.cs | 9 +- .../IndexerSearchTestBase.cs} | 26 ++---- .../PartialSeasonSearchFixture.cs | 52 +++++++++++ .../PartialSeasonSearch_EpisodeMatch.cs} | 11 ++- .../ProcessResultsFixture.cs | 6 +- .../TestSearch.cs | 26 +++--- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 20 ++--- .../PerformSearchFixture.cs | 54 ----------- .../PerformSearchFixture.cs | 81 ----------------- NzbDrone.Core/ContainerExtensions.cs | 2 +- .../DailyEpisodeSearch.cs | 25 +++--- .../Search => IndexerSearch}/EpisodeSearch.cs | 33 ++++--- .../PartialSeasonSearch.cs | 37 ++++---- .../Search => IndexerSearch}/SearchBase.cs | 22 ++--- .../Jobs/Implementations/EpisodeSearchJob.cs | 2 +- .../MetadataSource/TvRageMappingProvider.cs | 4 +- NzbDrone.Core/NzbDrone.Core.csproj | 8 +- NzbDrone.Core/Providers/SearchProvider.cs | 2 +- .../ReferenceData/SceneMappingProvider.cs | 10 ++- 24 files changed, 313 insertions(+), 347 deletions(-) rename NzbDrone.Core.Test/{ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs => IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearchFixture.cs} (65%) create mode 100644 NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearch_EpisodeMatch.cs rename NzbDrone.Core.Test/{ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs => IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearchFixture.cs} (53%) rename NzbDrone.Core.Test/{ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs => IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearch_EpisodeMatch.cs} (94%) rename NzbDrone.Core.Test/{ProviderTests/SearchTests => IndexerSearchTests}/GetSearchTitleFixture.cs (92%) rename NzbDrone.Core.Test/{ProviderTests/SearchTests/PerformSearchTestBase.cs => IndexerSearchTests/IndexerSearchTestBase.cs} (85%) create mode 100644 NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs rename NzbDrone.Core.Test/{ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs => IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs} (88%) rename NzbDrone.Core.Test/{ProviderTests/SearchTests => IndexerSearchTests}/ProcessResultsFixture.cs (99%) rename NzbDrone.Core.Test/{ProviderTests/SearchTests => IndexerSearchTests}/TestSearch.cs (71%) delete mode 100644 NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs delete mode 100644 NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs rename NzbDrone.Core/{Providers/Search => IndexerSearch}/DailyEpisodeSearch.cs (80%) rename NzbDrone.Core/{Providers/Search => IndexerSearch}/EpisodeSearch.cs (78%) rename NzbDrone.Core/{Providers/Search => IndexerSearch}/PartialSeasonSearch.cs (76%) rename NzbDrone.Core/{Providers/Search => IndexerSearch}/SearchBase.cs (90%) diff --git a/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs index d5cd64537..285669d3c 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System.Linq; +using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Core.Model; @@ -8,45 +9,88 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] - public class AllowedDownloadSpecificationFixture : CoreTest + public class AllowedDownloadSpecificationFixture : CoreTest { - private EpisodeParseResult parseResult; + private EpisodeParseResult _parseResult; - private Mock pass1; - private Mock pass2; - private Mock pass3; + private Mock _pass1; + private Mock _pass2; + private Mock _pass3; - private Mock fail1; - private Mock fail2; - private Mock fail3; + private Mock _fail1; + private Mock _fail2; + private Mock _fail3; [SetUp] public void Setup() { - pass1 = new Mock(); - pass2 = new Mock(); - pass3 = new Mock(); + _pass1 = new Mock(); + _pass2 = new Mock(); + _pass3 = new Mock(); - fail1 = new Mock(); - fail2 = new Mock(); - fail3 = new Mock(); + _fail1 = new Mock(); + _fail2 = new Mock(); + _fail3 = new Mock(); - pass1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); - pass2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); - pass3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); + _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); + _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); + _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); - fail1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); - fail2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); - fail3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); + _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); + _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); + _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); - parseResult = new EpisodeParseResult(); + _parseResult = new EpisodeParseResult(); } + private void GivenSpecifications(params Mock[] mocks) + { + Mocker.SetConstant(mocks.Select(c => c.Object)); + } + [Test] public void should_call_all_specifications() { - throw new InvalidAsynchronousStateException(); + GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3); + + Subject.GetDownloadDecision(_parseResult); + + _fail1.Verify(c => c.IsSatisfiedBy(_parseResult), Times.Once()); + _fail2.Verify(c => c.IsSatisfiedBy(_parseResult), Times.Once()); + _fail3.Verify(c => c.IsSatisfiedBy(_parseResult), Times.Once()); + _pass1.Verify(c => c.IsSatisfiedBy(_parseResult), Times.Once()); + _pass2.Verify(c => c.IsSatisfiedBy(_parseResult), Times.Once()); + _pass3.Verify(c => c.IsSatisfiedBy(_parseResult), Times.Once()); + } + + [Test] + public void should_return_rejected_if_one_of_specs_fail() + { + GivenSpecifications(_pass1, _fail1, _pass2, _pass3); + + var result = Subject.GetDownloadDecision(_parseResult); + + result.Approved.Should().BeFalse(); + } + + [Test] + public void should_return_pass_if_all_specs_pass() + { + GivenSpecifications(_pass1, _pass2, _pass3); + + var result = Subject.GetDownloadDecision(_parseResult); + + result.Approved.Should().BeTrue(); + } + + [Test] + public void should_have_same_number_of_rejections_as_specs_that_failed() + { + GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3); + + var result = Subject.GetDownloadDecision(_parseResult); + result.Rejections.Should().HaveCount(3); } } diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearchFixture.cs similarity index 65% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs rename to NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearchFixture.cs index 98a2e9fec..b1a834484 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearchFixture.cs @@ -1,17 +1,16 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Model; -using NzbDrone.Core.Providers.Search; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests.DailyEpisodeSearchTests { [TestFixture] - public class CheckReportFixture : TestBase + public class IndexerDailyEpisodeSearchFixture : CoreTest { private Series _series; private Episode _episode; @@ -43,8 +42,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests { _episodeParseResult.AirDate = null; - Mocker.Resolve() - .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult).Should().BeFalse(); + Subject.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult).Should().BeFalse(); } [Test] @@ -52,18 +50,16 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests { _episodeParseResult.AirDate = _episode.AirDate.Value.AddDays(-10); - Mocker.Resolve() - .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) - .Should() - .BeFalse(); + Subject.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) + .Should() + .BeFalse(); } [Test] public void should_not_return_error_when_airDates_match() { - Mocker.Resolve() - .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) - .Should().BeFalse(); + Subject.IsEpisodeMatch(_series, new {Episode = _episode}, _episodeParseResult) + .Should().BeTrue(); } } } diff --git a/NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearch_EpisodeMatch.cs b/NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearch_EpisodeMatch.cs new file mode 100644 index 000000000..fe4e1b41b --- /dev/null +++ b/NzbDrone.Core.Test/IndexerSearchTests/DailyEpisodeSearchTests/IndexerDailyEpisodeSearch_EpisodeMatch.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.IndexerSearch; +using NzbDrone.Core.Tv; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.IndexerSearchTests.DailyEpisodeSearchTests +{ + [TestFixture] + public class IndexerDailyEpisodeSearch_EpisodeMatch : IndexerSearchTestBase + { + [Test] + public void should_fetch_results_from_indexers() + { + WithValidIndexers(); + + + Subject.PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); + } + + [Test] + public void should_log_error_when_fetching_from_indexer_fails() + { + WithBrokenIndexers(); + + Mocker.Resolve() + .PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(0); + + ExceptionVerification.ExpectedErrors(2); + } + } +} diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearchFixture.cs similarity index 53% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs rename to NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearchFixture.cs index 3414ce238..23d836142 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearchFixture.cs @@ -1,52 +1,37 @@ -using System; using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Tv; -using NzbDrone.Core.Model; -using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Search; - using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests.EpisodeSearchTests { [TestFixture] - public class PerformSearchFixture : PerformSearchTestBase + public class IndexerEpisodeSearchFixture : IndexerSearchTestBase { - [Test] - public void should_throw_if_episode_is_null() - { - Episode nullEpisode = null; - Assert.Throws(() => - Mocker.Resolve() - .PerformSearch(_series, new { Episode = nullEpisode }, notification)); - } [Test] public void should_fetch_results_from_indexers() { WithValidIndexers(); - Mocker.Resolve() - .PerformSearch(_series, new {Episode = _episode}, notification) - .Should() - .HaveCount(20); + Subject + .PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); } [Test] public void should_log_error_when_fetching_from_indexer_fails() { - WithInvalidIndexers(); + WithBrokenIndexers(); - Mocker.Resolve() - .PerformSearch(_series, new { Episode = _episode }, notification) - .Should() - .HaveCount(0); + Subject + .PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(0); ExceptionVerification.ExpectedErrors(2); } @@ -60,10 +45,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests WithValidIndexers(); - Mocker.Resolve() - .PerformSearch(_series, new { Episode = _episode }, notification) - .Should() - .HaveCount(20); + Subject + .PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); _indexer1.Verify(v => v.FetchEpisode(_series.Title, 10, 5), Times.Once()); _indexer2.Verify(v => v.FetchEpisode(_series.Title, 10, 5), Times.Once()); @@ -78,10 +63,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests WithValidIndexers(); - Mocker.Resolve() - .PerformSearch(_series, new { Episode = _episode }, notification) - .Should() - .HaveCount(20); + Subject + .PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); _indexer1.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once()); _indexer2.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once()); @@ -94,10 +79,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests WithValidIndexers(); - Mocker.Resolve() - .PerformSearch(_series, new { Episode = _episode }, notification) - .Should() - .HaveCount(20); + Subject + .PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); _indexer1.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once()); _indexer2.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once()); diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearch_EpisodeMatch.cs similarity index 94% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs rename to NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearch_EpisodeMatch.cs index 37cad8601..6b3c4a289 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearch_EpisodeMatch.cs @@ -1,16 +1,16 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Model; -using NzbDrone.Core.Providers.Search; +using NzbDrone.Core.Tv; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests.EpisodeSearchTests { [TestFixture] - public class CheckReportFixture : TestBase + public class IndexerEpisodeSearch_EpisodeMatch : TestBase { private Series _series; private Episode _episode; @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests Mocker.Resolve() .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) .Should() - .BeFalse(); + .BeTrue(); } [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs similarity index 92% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs rename to NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs index d47459c84..126895a23 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Search; - using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.ProviderTests.SearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests { public class GetSearchTitleFixture : TestBase { diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs b/NzbDrone.Core.Test/IndexerSearchTests/IndexerSearchTestBase.cs similarity index 85% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs rename to NzbDrone.Core.Test/IndexerSearchTests/IndexerSearchTestBase.cs index cdca2fb20..c38d0908f 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/IndexerSearchTestBase.cs @@ -1,25 +1,22 @@ -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Indexers; -using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.ProviderTests.SearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests { - public class PerformSearchTestBase : TestBase + public abstract class IndexerSearchTestBase : CoreTest + where TSearch : SearchBase { protected Series _series; protected Episode _episode; - protected List _episodes; protected ProgressNotification notification = new ProgressNotification("Testing"); protected Mock _indexer1; @@ -40,13 +37,6 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests .With(e => e.Series = _series) .Build(); - _episodes = Builder - .CreateListOfSize(10) - .All() - .With(e => e.SeriesId = _series.Id) - .With(e => e.Series = _series) - .Build() - .ToList(); _parseResults = Builder .CreateListOfSize(10) @@ -78,7 +68,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests .Returns(_parseResults); } - protected void WithInvalidIndexers() + protected void WithBrokenIndexers() { _indexer1.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny())) .Throws(new Exception()); diff --git a/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs new file mode 100644 index 000000000..4d1ef27a9 --- /dev/null +++ b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.IndexerSearch; +using NzbDrone.Core.Tv; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests +{ + [TestFixture] + public class PartialSeasonSearchFixture : IndexerSearchTestBase + { + + [Test] + public void should_fetch_results_from_indexers() + { + WithValidIndexers(); + + Subject.PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); + } + + [Test] + public void should_log_error_when_fetching_from_indexer_fails() + { + WithBrokenIndexers(); + + Subject.PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(0); + + ExceptionVerification.ExpectedErrors(4); + } + + [Test] + public void should_hit_each_indexer_once_for_each_prefix() + { + WithValidIndexers(); + + Subject.PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); + + _indexer1.Verify(v => v.FetchPartialSeason(_series.Title, 1, 0), Times.Once()); + _indexer1.Verify(v => v.FetchPartialSeason(_series.Title, 1, 1), Times.Once()); + _indexer2.Verify(v => v.FetchPartialSeason(_series.Title, 1, 0), Times.Once()); + _indexer2.Verify(v => v.FetchPartialSeason(_series.Title, 1, 1), Times.Once()); + } + } +} diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs similarity index 88% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs rename to NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs index 9b6fb5217..1f4906d2e 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs @@ -1,18 +1,17 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Model; -using NzbDrone.Core.Providers.Search; - +using NzbDrone.Core.Tv; using NzbDrone.Test.Common; -namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests { [TestFixture] - public class CheckReportFixture : TestBase + public class PartialSeasonSearch_EpisodeMatch : TestBase { private Series _series; private List _episodes; diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/ProcessResultsFixture.cs similarity index 99% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs rename to NzbDrone.Core.Test/IndexerSearchTests/ProcessResultsFixture.cs index 613ca9087..451b3dd99 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/ProcessResultsFixture.cs @@ -1,4 +1,4 @@ -/* +/* using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; @@ -230,3 +230,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests } } */ + +namespace NzbDrone.Core.Test.IndexerSearchTests +{ +} \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs b/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs similarity index 71% rename from NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs rename to NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs index 7319df2fb..333fa5882 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs @@ -1,41 +1,39 @@ -using System; +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using NLog; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Indexers; +using NzbDrone.Core.Model; using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; -using NzbDrone.Core.Model; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Providers.Search; -namespace NzbDrone.Core.Test.ProviderTests.SearchTests +namespace NzbDrone.Core.Test.IndexerSearchTests { public class TestSearch : SearchBase { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, - IIndexerService indexerService, SceneMappingService sceneMappingService, + IIndexerService indexerService, ISceneMappingService sceneMappingService, DownloadDirector downloadDirector, ISeriesRepository seriesRepository) : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, downloadDirector) { } - public override List PerformSearch(Series series, dynamic options, Model.Notification.ProgressNotification notification) + public override List PerformSearch(Series series, List episodes, Model.Notification.ProgressNotification notification) { - if (options.Episode == null) - throw new ArgumentException("Episode is invalid"); - - notification.CurrentMessage = "Looking for " + options.Episode; + var episode = episodes.Single(); var reports = new List(); var title = GetSearchTitle(series); - var seasonNumber = options.Episode.SeasonNumber; - var episodeNumber = options.Episode.EpisodeNumber; + var seasonNumber = episode.SeasonNumber; + var episodeNumber = episode.EpisodeNumber; Parallel.ForEach(_indexerService.GetEnabledIndexers(), indexer => { @@ -47,7 +45,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests catch (Exception e) { logger.ErrorException(String.Format("An error has occurred while searching for {0}-S{1:00}E{2:00} from: {3}", - series.Title, options.SeasonNumber, options.EpisodeNumber, indexer.Name), e); + series.Title, episode.SeasonNumber, episode.EpisodeNumber, indexer.Name), e); } }); diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index df839656e..36d6d7c52 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -136,6 +136,16 @@ + + + + + + + + + + @@ -146,16 +156,6 @@ - - - - - - - - - - diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs deleted file mode 100644 index a363047e9..000000000 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Model; -using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Search; - -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests -{ - [TestFixture] - public class PerformSearchFixture : PerformSearchTestBase - { - [Test] - public void should_throw_if_episode_is_null() - { - Episode nullEpisode = null; - Assert.Throws(() => - Mocker.Resolve() - .PerformSearch(_series, new { Episode = nullEpisode }, notification)); - } - - [Test] - public void should_fetch_results_from_indexers() - { - WithValidIndexers(); - - Mocker.Resolve() - .PerformSearch(_series, new {Episode = _episode}, notification) - .Should() - .HaveCount(20); - } - - [Test] - public void should_log_error_when_fetching_from_indexer_fails() - { - WithInvalidIndexers(); - - Mocker.Resolve() - .PerformSearch(_series, new { Episode = _episode }, notification) - .Should() - .HaveCount(0); - - ExceptionVerification.ExpectedErrors(2); - } - } -} diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs deleted file mode 100644 index 41f4d45c0..000000000 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Model; -using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Search; - -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests -{ - [TestFixture] - public class PerformSearchFixture : PerformSearchTestBase - { - [Test] - public void should_throw_if_season_number_is_less_than_zero() - { - Assert.Throws(() => - Mocker.Resolve() - .PerformSearch(_series, new - { - SeasonNumber = -1, - Episodes = new List{ new Episode() } - }, notification)); - } - - [Test] - public void should_throw_if_episodes_is_empty() - { - Assert.Throws(() => - Mocker.Resolve() - .PerformSearch(_series, new { SeasonNumber = 10, Episodes = new List() }, notification)); - } - - [Test] - public void should_fetch_results_from_indexers() - { - WithValidIndexers(); - - Mocker.Resolve() - .PerformSearch(_series, new { SeasonNumber = 1, Episodes = _episodes }, notification) - .Should() - .HaveCount(40); - } - - [Test] - public void should_log_error_when_fetching_from_indexer_fails() - { - WithInvalidIndexers(); - - Mocker.Resolve() - .PerformSearch(_series, new { SeasonNumber = 1, Episodes = _episodes }, notification) - .Should() - .HaveCount(0); - - ExceptionVerification.ExpectedErrors(4); - } - - [Test] - public void should_hit_each_indexer_once_for_each_prefix() - { - WithValidIndexers(); - - Mocker.Resolve() - .PerformSearch(_series, new { SeasonNumber = 1, Episodes = _episodes }, notification) - .Should() - .HaveCount(40); - - _indexer1.Verify(v => v.FetchPartialSeason(_series.Title, 1, 0), Times.Once()); - _indexer1.Verify(v => v.FetchPartialSeason(_series.Title, 1, 1), Times.Once()); - _indexer2.Verify(v => v.FetchPartialSeason(_series.Title, 1, 0), Times.Once()); - _indexer2.Verify(v => v.FetchPartialSeason(_series.Title, 1, 1), Times.Once()); - } - } -} diff --git a/NzbDrone.Core/ContainerExtensions.cs b/NzbDrone.Core/ContainerExtensions.cs index 2f18a2e1e..6bdd41ae4 100644 --- a/NzbDrone.Core/ContainerExtensions.cs +++ b/NzbDrone.Core/ContainerExtensions.cs @@ -7,9 +7,9 @@ using NLog; using NzbDrone.Common; using NzbDrone.Core.Datastore; using NzbDrone.Core.ExternalNotification; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Indexers; using NzbDrone.Core.Instrumentation; -using NzbDrone.Core.Providers.Search; namespace NzbDrone.Core { diff --git a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs b/NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs similarity index 80% rename from NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs rename to NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs index e56e67c5c..25f68d6f1 100644 --- a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs +++ b/NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs @@ -1,23 +1,25 @@ -using System; +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using NLog; +using NzbDrone.Common.EnsureThat; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; -using NzbDrone.Core.ReferenceData; -using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.ReferenceData; +using NzbDrone.Core.Tv; -namespace NzbDrone.Core.Providers.Search +namespace NzbDrone.Core.IndexerSearch { public class DailyEpisodeSearch : SearchBase { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public DailyEpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, - SceneMappingService sceneMappingService, DownloadDirector downloadDirector, + ISceneMappingService sceneMappingService, IDownloadDirector downloadDirector, ISeriesRepository seriesRepository) : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, downloadDirector) @@ -28,12 +30,11 @@ namespace NzbDrone.Core.Providers.Search { } - public override List PerformSearch(Series series, dynamic options, ProgressNotification notification) + public override List PerformSearch(Series series, List episodes, ProgressNotification notification) { - if (options.Episode == null) - throw new ArgumentException("Episode is invalid"); + var episode = episodes.Single(); - notification.CurrentMessage = "Looking for " + options.Episode; + notification.CurrentMessage = "Looking for " + episode; var reports = new List(); var title = GetSearchTitle(series); @@ -42,13 +43,13 @@ namespace NzbDrone.Core.Providers.Search { try { - reports.AddRange(indexer.FetchDailyEpisode(title, options.Episode.AirDate)); + reports.AddRange(indexer.FetchDailyEpisode(title, episode.AirDate.Value)); } catch (Exception e) { logger.ErrorException(String.Format("An error has occurred while searching for {0} - {1:yyyy-MM-dd} from: {2}", - series.Title, options.Episode.AirDate, indexer.Name), e); + series.Title, episode.AirDate, indexer.Name), e); } }); diff --git a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs b/NzbDrone.Core/IndexerSearch/EpisodeSearch.cs similarity index 78% rename from NzbDrone.Core/Providers/Search/EpisodeSearch.cs rename to NzbDrone.Core/IndexerSearch/EpisodeSearch.cs index 1faa67b64..8772e5b96 100644 --- a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs +++ b/NzbDrone.Core/IndexerSearch/EpisodeSearch.cs @@ -1,23 +1,24 @@ -using System; +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using NLog; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; -using NzbDrone.Core.ReferenceData; -using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.ReferenceData; +using NzbDrone.Core.Tv; -namespace NzbDrone.Core.Providers.Search +namespace NzbDrone.Core.IndexerSearch { public class EpisodeSearch : SearchBase { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public EpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, - SceneMappingService sceneMappingService, DownloadDirector downloadDirector, + ISceneMappingService sceneMappingService, IDownloadDirector downloadDirector, ISeriesRepository seriesRepository) : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, downloadDirector) @@ -28,29 +29,27 @@ namespace NzbDrone.Core.Providers.Search { } - public override List PerformSearch(Series series, dynamic options, ProgressNotification notification) + public override List PerformSearch(Series series, List episodes, ProgressNotification notification) { //Todo: Daily and Anime or separate them out? //Todo: Epsiodes that use scene numbering - if (options.Episode == null) - throw new ArgumentException("Episode is invalid"); + var episode = episodes.Single(); - notification.CurrentMessage = "Looking for " + options.Episode; var reports = new List(); var title = GetSearchTitle(series); - var seasonNumber = options.Episode.SeasonNumber; - var episodeNumber = options.Episode.EpisodeNumber; + var seasonNumber = episode.SeasonNumber; + var episodeNumber = episode.EpisodeNumber; if (series.UseSceneNumbering) { - if (options.Episode.SceneSeasonNumber > 0 && options.Episode.SceneEpisodeNumber > 0) + if (episode.SceneSeasonNumber > 0 && episode.SceneEpisodeNumber > 0) { - logger.Trace("Using Scene Numbering for: {0}", options.Episode); - seasonNumber = options.Episode.SceneSeasonNumber; - episodeNumber = options.Episode.SceneEpisodeNumber; + logger.Trace("Using Scene Numbering for: {0}", episode); + seasonNumber = episode.SceneSeasonNumber; + episodeNumber = episode.SceneEpisodeNumber; } } @@ -64,7 +63,7 @@ namespace NzbDrone.Core.Providers.Search catch (Exception e) { logger.ErrorException(String.Format("An error has occurred while searching for {0}-S{1:00}E{2:00} from: {3}", - series.Title, options.Episode.SeasonNumber, options.Episode.EpisodeNumber, indexer.Name), e); + series.Title, episode.SeasonNumber, episode.EpisodeNumber, indexer.Name), e); } }); diff --git a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs b/NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs similarity index 76% rename from NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs rename to NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs index 462302312..d816e7c8c 100644 --- a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs +++ b/NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs @@ -1,26 +1,24 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; using NLog; -using NzbDrone.Core.DecisionEngine.Specifications; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; -using NzbDrone.Core.ReferenceData; -using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.ReferenceData; +using NzbDrone.Core.Tv; -namespace NzbDrone.Core.Providers.Search +namespace NzbDrone.Core.IndexerSearch { public class PartialSeasonSearch : SearchBase { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public PartialSeasonSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, - SceneMappingService sceneMappingService, DownloadDirector downloadDirector, + ISceneMappingService sceneMappingService, IDownloadDirector downloadDirector, ISeriesRepository seriesRepository) : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, downloadDirector) @@ -31,20 +29,17 @@ namespace NzbDrone.Core.Providers.Search { } - public override List PerformSearch(Series series, dynamic options, ProgressNotification notification) + public override List PerformSearch(Series series, List episodes, ProgressNotification notification) { - if (options.SeasonNumber == null || options.SeasonNumber < 0) - throw new ArgumentException("SeasonNumber is invalid"); + var seasons = episodes.Select(c => c.SeasonNumber).Distinct().ToList(); - if (options.Episodes == null) - throw new ArgumentException("Episodes were not provided"); + if (seasons.Count > 1) + { + throw new ArgumentOutOfRangeException("episodes", "episode list contains episodes from more than one season"); + } - List episodes = options.Episodes; - - if (!episodes.Any()) - throw new ArgumentException("Episodes were not provided"); - - notification.CurrentMessage = String.Format("Looking for {0} - Season {1}", series.Title, options.SeasonNumber); + var seasonNumber = seasons[0]; + notification.CurrentMessage = String.Format("Looking for {0} - Season {1}", series.Title, seasonNumber); var reports = new List(); object reportsLock = new object(); @@ -62,7 +57,7 @@ namespace NzbDrone.Core.Providers.Search { lock (reportsLock) { - reports.AddRange(indexer.FetchPartialSeason(title, options.SeasonNumber, prefix)); + reports.AddRange(indexer.FetchPartialSeason(title, seasonNumber, prefix)); } } @@ -71,7 +66,7 @@ namespace NzbDrone.Core.Providers.Search logger.ErrorException( String.Format( "An error has occurred while searching for {0} Season {1:00} Prefix: {2} from: {3}", - series.Title, options.SeasonNumber, prefix, indexer.Name), + series.Title, seasonNumber, prefix, indexer.Name), e); } }); diff --git a/NzbDrone.Core/Providers/Search/SearchBase.cs b/NzbDrone.Core/IndexerSearch/SearchBase.cs similarity index 90% rename from NzbDrone.Core/Providers/Search/SearchBase.cs rename to NzbDrone.Core/IndexerSearch/SearchBase.cs index 14b508c73..83476cfe3 100644 --- a/NzbDrone.Core/Providers/Search/SearchBase.cs +++ b/NzbDrone.Core/IndexerSearch/SearchBase.cs @@ -1,17 +1,17 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using NLog; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; -using NzbDrone.Core.ReferenceData; -using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.ReferenceData; +using NzbDrone.Core.Tv; -namespace NzbDrone.Core.Providers.Search +namespace NzbDrone.Core.IndexerSearch { public abstract class SearchBase { @@ -19,14 +19,14 @@ namespace NzbDrone.Core.Providers.Search protected readonly IEpisodeService _episodeService; protected readonly DownloadProvider _downloadProvider; protected readonly IIndexerService _indexerService; - protected readonly SceneMappingService _sceneMappingService; - protected readonly DownloadDirector DownloadDirector; + protected readonly ISceneMappingService _sceneMappingService; + protected readonly IDownloadDirector DownloadDirector; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); protected SearchBase(ISeriesRepository seriesRepository, IEpisodeService episodeService, DownloadProvider downloadProvider, - IIndexerService indexerService, SceneMappingService sceneMappingService, - DownloadDirector downloadDirector) + IIndexerService indexerService, ISceneMappingService sceneMappingService, + IDownloadDirector downloadDirector) { _seriesRepository = seriesRepository; _episodeService = episodeService; @@ -40,10 +40,10 @@ namespace NzbDrone.Core.Providers.Search { } - public abstract List PerformSearch(Series series, dynamic options, ProgressNotification notification); + public abstract List PerformSearch(Series series, List episodes, ProgressNotification notification); public abstract bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult); - public virtual List Search(Series series, dynamic options, ProgressNotification notification) + public virtual List Search(Series series, dynamic options, ProgressNotification notification) { if (options == null) throw new ArgumentNullException(options); diff --git a/NzbDrone.Core/Jobs/Implementations/EpisodeSearchJob.cs b/NzbDrone.Core/Jobs/Implementations/EpisodeSearchJob.cs index 379fda020..0e30ce469 100644 --- a/NzbDrone.Core/Jobs/Implementations/EpisodeSearchJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/EpisodeSearchJob.cs @@ -1,8 +1,8 @@ using System; using NLog; using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers.Search; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Jobs.Implementations diff --git a/NzbDrone.Core/MetadataSource/TvRageMappingProvider.cs b/NzbDrone.Core/MetadataSource/TvRageMappingProvider.cs index 0e0ba04bd..cc3599d17 100644 --- a/NzbDrone.Core/MetadataSource/TvRageMappingProvider.cs +++ b/NzbDrone.Core/MetadataSource/TvRageMappingProvider.cs @@ -11,13 +11,13 @@ namespace NzbDrone.Core.MetadataSource { public class TvRageMappingProvider { - private readonly SceneMappingService _sceneMappingService; + private readonly ISceneMappingService _sceneMappingService; private readonly TvRageProxy _tvRageProxy; private readonly IEpisodeService _episodeService; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public TvRageMappingProvider(SceneMappingService sceneMappingService, + public TvRageMappingProvider(ISceneMappingService sceneMappingService, TvRageProxy tvRageProxy, IEpisodeService episodeService) { _sceneMappingService = sceneMappingService; diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index b15f62fd2..48604e7e3 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -212,6 +212,10 @@ + + + + @@ -322,10 +326,6 @@ - - - - diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index 0e52836ee..b92bde4b2 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Linq; using NLog; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Tv; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers.Search; namespace NzbDrone.Core.Providers { diff --git a/NzbDrone.Core/ReferenceData/SceneMappingProvider.cs b/NzbDrone.Core/ReferenceData/SceneMappingProvider.cs index 519a57a3a..abac0e5a0 100644 --- a/NzbDrone.Core/ReferenceData/SceneMappingProvider.cs +++ b/NzbDrone.Core/ReferenceData/SceneMappingProvider.cs @@ -5,7 +5,15 @@ using NzbDrone.Core.Lifecycle; namespace NzbDrone.Core.ReferenceData { - public class SceneMappingService : IInitializable + public interface ISceneMappingService + { + void UpdateMappings(); + string GetSceneName(int tvdbId, int seasonNumber = -1); + Nullable GetTvDbId(string cleanName); + string GetCleanName(int tvdbId); + } + + public class SceneMappingService : IInitializable, ISceneMappingService { private readonly ISceneMappingRepository _repository; private readonly ISceneMappingProxy _sceneMappingProxy;