diff --git a/NzbDrone.Core.Test/SearchProviderTest_Episode.cs b/NzbDrone.Core.Test/SearchProviderTest_Episode.cs index 2ec34e751..5105eac7f 100644 --- a/NzbDrone.Core.Test/SearchProviderTest_Episode.cs +++ b/NzbDrone.Core.Test/SearchProviderTest_Episode.cs @@ -198,10 +198,6 @@ public void processResults_failed_download_should_not_check_the_rest() ExceptionVerification.ExcpectedErrors(1); } - - - - [Test] public void start_should_search_all_providers() { @@ -233,6 +229,10 @@ public void start_should_search_all_providers() .Setup(c => c.GetEnabledIndexers()) .Returns(indexers); + mocker.GetMock() + .Setup(c => c.GetSeries(It.IsAny())) + .Returns(episode.Series); + mocker.GetMock() .Setup(c => c.IsQualityNeeded(It.IsAny())).Returns(false); @@ -273,7 +273,6 @@ public void start_should_use_scene_name_to_search() indexer1.Setup(c => c.FetchEpisode("The Daily Show", episode.SeasonNumber, episode.EpisodeNumber)) .Returns(parseResults).Verifiable(); - var indexer2 = new Mock(); indexer2.Setup(c => c.FetchEpisode("The Daily Show", episode.SeasonNumber, episode.EpisodeNumber)) .Returns(parseResults).Verifiable(); @@ -284,6 +283,10 @@ public void start_should_use_scene_name_to_search() .Setup(c => c.GetEnabledIndexers()) .Returns(indexers); + mocker.GetMock() + .Setup(c => c.GetSeries(It.IsAny())) + .Returns(episode.Series); + mocker.GetMock() .Setup(c => c.IsQualityNeeded(It.IsAny())).Returns(false); @@ -303,7 +306,6 @@ public void start_should_use_scene_name_to_search() indexer2.VerifyAll(); } - [Test] public void start_failed_indexer_should_not_break_job() { @@ -341,6 +343,10 @@ public void start_failed_indexer_should_not_break_job() .Setup(c => c.GetEnabledIndexers()) .Returns(indexers); + mocker.GetMock() + .Setup(c => c.GetSeries(It.IsAny())) + .Returns(episode.Series); + mocker.GetMock() .Setup(c => c.IsQualityNeeded(It.IsAny())).Returns(false); @@ -363,7 +369,6 @@ public void start_failed_indexer_should_not_break_job() indexer3.VerifyAll(); } - [Test] public void start_no_episode_found_should_return_with_error_logged() { @@ -381,5 +386,51 @@ public void start_no_episode_found_should_return_with_error_logged() mocker.VerifyAllMocks(); ExceptionVerification.ExcpectedErrors(1); } + + [Test] + public void episode_search_should_call_get_series() + { + var parseResults = Builder.CreateListOfSize(4) + .Build(); + + var episode = Builder.CreateNew() + .With(c => c.Series = Builder.CreateNew().Build()) + .With(c => c.SeasonNumber = 12) + .Build(); + + var mocker = new AutoMoqer(MockBehavior.Strict); + + mocker.GetMock() + .Setup(c => c.GetEpisode(episode.EpisodeId)) + .Returns(episode); + + var indexer1 = new Mock(); + indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber)) + .Returns(parseResults).Verifiable(); + + var indexers = new List { indexer1.Object }; + + mocker.GetMock() + .Setup(c => c.GetEnabledIndexers()) + .Returns(indexers); + + mocker.GetMock() + .Setup(c => c.IsQualityNeeded(It.IsAny())).Returns(false); + + mocker.GetMock() + .Setup(s => s.GetSceneName(It.IsAny())).Returns(""); + + mocker.GetMock() + .Setup(s => s.GetSeries(It.IsAny())).Returns(episode.Series); + + //Act + mocker.Resolve().EpisodeSearch(new ProgressNotification("Test"), episode.EpisodeId); + + + //Assert + mocker.VerifyAllMocks(); + ExceptionVerification.ExcpectedWarns(1); + indexer1.VerifyAll(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index 3378699f7..353a05ef1 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -150,8 +150,7 @@ public virtual bool EpisodeSearch(ProgressNotification notification, int episode } notification.CurrentMessage = "Searching for " + episode; - - var series = episode.Series; + var series = _seriesProvider.GetSeries(episode.SeriesId); var indexers = _indexerProvider.GetEnabledIndexers(); var reports = new List();