diff --git a/NzbDrone.Core.Test/JobTests/SearchJobTest.cs b/NzbDrone.Core.Test/JobTests/EpisodeSearchJobTest.cs
similarity index 95%
rename from NzbDrone.Core.Test/JobTests/SearchJobTest.cs
rename to NzbDrone.Core.Test/JobTests/EpisodeSearchJobTest.cs
index e3c6a5a52..d5333766f 100644
--- a/NzbDrone.Core.Test/JobTests/SearchJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/EpisodeSearchJobTest.cs
@@ -10,7 +10,7 @@ using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
- public class SearchJobTest:CoreTest
+ public class EpisodeSearchJobTest:CoreTest
{
[TestCase(0)]
[TestCase(-1)]
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 46aad0b85..905cd37ac 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -142,7 +142,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -190,17 +199,13 @@
-
-
-
-
-
+
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/GetSeriesTitleFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/GetSeriesTitleFixture.cs
deleted file mode 100644
index 2fad2dfa1..000000000
--- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/GetSeriesTitleFixture.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using NUnit.Framework;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Repository;
-using NzbDrone.Test.Common;
-
-namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
-{
- public class GetSeriesTitleFixture : TestBase
- {
- private Series _series;
- private const string SCENE_NAME = "Scandal";
-
- [SetUp]
- public void Setup()
- {
- _series = Builder
- .CreateNew()
- .With(s => s.Title = "Scandal (2012)")
- .Build();
- }
-
- private void WithSceneName()
- {
- Mocker.GetMock()
- .Setup(s => s.GetSceneName(_series.SeriesId))
- .Returns("Scandal");
- }
-
- [Test]
- public void should_return_scene_name_when_sceneName_is_available()
- {
- WithSceneName();
-
- Mocker.Resolve().GetSeriesTitle(_series).Should().Be(SCENE_NAME);
- }
-
- [Test]
- public void should_return_seriesTitle_when_sceneName_is_not_available()
- {
- Mocker.Resolve().GetSeriesTitle(_series).Should().Be(_series.Title);
- }
-
- [TestCase("Mike & Molly", "Mike and Molly")]
- [TestCase("Franklin & Bash", "Franklin and Bash")]
- [TestCase("Law & Order", "Law and Order")]
- public void should_replace_ampersand_with_and_when_returning_title(string seriesTitle, string expectedTitle)
- {
- _series.Title = seriesTitle;
-
- Mocker.Resolve().GetSeriesTitle(_series).Should().Be(expectedTitle);
- }
- }
-}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/PerformSearchFixture.cs
deleted file mode 100644
index f3de2b4c2..000000000
--- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/PerformSearchFixture.cs
+++ /dev/null
@@ -1,282 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Indexer;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common;
-
-namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
-{
- public class PerformSearchFixture : CoreTest
- {
- private const string SCENE_NAME = "Scene Name";
- private const int SEASON_NUMBER = 5;
- private const int EPISODE_NUMBER = 1;
- private const int PARSE_RESULT_COUNT = 10;
-
- private Mock _episodeIndexer1;
- private Mock _episodeIndexer2;
- private Mock _brokenIndexer;
- private Mock _nullIndexer;
-
- private List _indexers;
-
- private Series _series;
- private IList _episodes;
-
- [SetUp]
- public void Setup()
- {
- var parseResults = Builder.CreateListOfSize(PARSE_RESULT_COUNT)
- .Build();
-
- _series = Builder.CreateNew()
- .Build();
-
- _episodes = Builder.CreateListOfSize(1)
- .Build();
-
- BuildIndexers(parseResults);
-
- _indexers = new List { _episodeIndexer1.Object, _episodeIndexer2.Object };
-
- Mocker.GetMock()
- .Setup(c => c.GetEnabledIndexers())
- .Returns(_indexers);
- }
-
- private void BuildIndexers(IList parseResults)
- {
- _episodeIndexer1 = new Mock();
- _episodeIndexer1.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer1.Setup(c => c.FetchDailyEpisode(It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer1.Setup(c => c.FetchSeason(It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer1.Setup(c => c.FetchPartialSeason(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer1.Setup(s => s.Name).Returns("Episode Indexer 1");
-
- _episodeIndexer2 = new Mock();
- _episodeIndexer2.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer2.Setup(c => c.FetchDailyEpisode(It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer2.Setup(c => c.FetchSeason(It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer2.Setup(c => c.FetchPartialSeason(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer2.Setup(s => s.Name).Returns("Episode Indexer 2");
-
- _brokenIndexer = new Mock();
- _brokenIndexer.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Throws(new Exception());
- _brokenIndexer.Setup(s => s.Name).Returns("Broken Indexer");
-
- _nullIndexer = new Mock();
- _nullIndexer.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns>(null);
- _nullIndexer.Setup(s => s.Name).Returns("Null Indexer");
- }
-
- private void WithTwoGoodOneBrokenIndexer()
- {
- _indexers = new List { _episodeIndexer1.Object, _brokenIndexer.Object, _episodeIndexer2.Object };
-
- Mocker.GetMock()
- .Setup(c => c.GetEnabledIndexers())
- .Returns(_indexers);
- }
-
- private void WithNullIndexers()
- {
- _indexers = new List { _nullIndexer.Object, _nullIndexer.Object };
-
- Mocker.GetMock()
- .Setup(c => c.GetEnabledIndexers())
- .Returns(_indexers);
- }
-
- private void WithSceneName()
- {
- Mocker.GetMock()
- .Setup(s => s.GetSceneName(_series.SeriesId)).Returns(SCENE_NAME);
- }
-
- private void With30Episodes()
- {
- _episodes = Builder.CreateListOfSize(30)
- .Build();
- }
-
- private void WithNullEpisodes()
- {
- _episodes = null;
- }
-
- private void VerifyFetchEpisode(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchEpisode(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchEpisode(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchDailyEpisode(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchDailyEpisode(_series.Title, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchDailyEpisode(_series.Title, It.IsAny())
- , times);
- }
-
- private void VerifyFetchEpisodeWithSceneName(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchEpisode(SCENE_NAME, SEASON_NUMBER, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchEpisode(SCENE_NAME, SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchEpisodeBrokenIndexer(Times times)
- {
- _brokenIndexer.Verify(v => v.FetchEpisode(It.IsAny(), SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchPartialSeason(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchPartialSeason(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchPartialSeason(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchSeason(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchSeason(_series.Title, SEASON_NUMBER), times);
- _episodeIndexer1.Verify(v => v.FetchSeason(_series.Title, SEASON_NUMBER), times);
- }
-
- [Test]
- public void PerformSearch_should_search_all_enabled_providers()
- {
- //Act
- var result = Mocker.Resolve().PerformEpisodeSearch(_series, SEASON_NUMBER, _episodes.First().EpisodeNumber);
-
- //Assert
- VerifyFetchEpisode(Times.Once());
- result.Should().HaveCount(PARSE_RESULT_COUNT * 2);
- }
-
- [Test]
- public void broken_indexer_should_not_block_other_indexers()
- {
- //Setup
- WithTwoGoodOneBrokenIndexer();
-
- //Act
- var result = Mocker.Resolve().PerformEpisodeSearch(_series, SEASON_NUMBER, EPISODE_NUMBER);
-
- //Assert
- result.Should().HaveCount(PARSE_RESULT_COUNT * 2);
-
- VerifyFetchEpisode(Times.Once());
- VerifyFetchEpisodeBrokenIndexer(Times.Once());
-
- Mocker.GetMock().Verify(c => c.GetSceneName(_series.SeriesId),
- Times.Once());
-
- ExceptionVerification.ExpectedErrors(1);
- }
-
- [Test]
- public void PerformSearch_for_episode_should_call_FetchEpisode()
- {
- //Act
- var result = Mocker.Resolve().PerformEpisodeSearch(_series, SEASON_NUMBER, EPISODE_NUMBER);
-
- //Assert
- result.Should().HaveCount(PARSE_RESULT_COUNT * 2);
-
- VerifyFetchEpisode(Times.Once());
- }
-
- [Test]
- public void PerformSearch_for_daily_episode_should_call_FetchEpisode()
- {
- //Setup
- _series.IsDaily = true;
-
- //Act
- var result = Mocker.Resolve().PerformDailyEpisodeSearch(_series, _episodes.First());
-
- //Assert
- result.Should().HaveCount(PARSE_RESULT_COUNT * 2);
-
- VerifyFetchDailyEpisode(Times.Once());
- }
-
- [Test]
- public void PerformSearch_for_partial_season_should_call_FetchPartialSeason()
- {
- With30Episodes();
-
- //Act
- var result = Mocker.Resolve().PerformPartialSeasonSearch(_series, SEASON_NUMBER, new List{0, 1, 2, 3});
-
- //Assert
- result.Should().HaveCount(80);
- VerifyFetchPartialSeason(Times.Exactly(4));
- }
-
- [Test]
- public void PerformSearch_for_season_should_call_FetchSeason()
- {
- WithNullEpisodes();
-
- //Act
- var result = Mocker.Resolve().PerformSeasonSearch(_series, SEASON_NUMBER);
-
- //Assert
- result.Should().HaveCount(20);
- VerifyFetchSeason(Times.Once());
- }
-
- [Test]
- public void PerformSearch_should_return_empty_list_when_results_from_indexers_are_null()
- {
- //Setup
- WithNullIndexers();
-
- //Act
- var result = Mocker.Resolve().PerformEpisodeSearch(_series, SEASON_NUMBER, EPISODE_NUMBER);
-
- //Assert
- result.Should().HaveCount(0);
- ExceptionVerification.ExpectedErrors(2);
- }
-
- [Test]
- public void should_use_scene_name_to_search_for_episode_when_avilable()
- {
- WithSceneName();
-
- Mocker.Resolve().PerformEpisodeSearch(_series, SEASON_NUMBER, EPISODE_NUMBER);
-
- VerifyFetchEpisodeWithSceneName(Times.Once());
- }
- }
-}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs
deleted file mode 100644
index 72783d57c..000000000
--- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessDailySearchResultsFixture.cs
+++ /dev/null
@@ -1,283 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Model.Notification;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.DecisionEngine;
-using NzbDrone.Core.Providers.Indexer;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
-using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common;
-using NzbDrone.Test.Common.AutoMoq;
-
-namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
-{
- [TestFixture]
- // ReSharper disable InconsistentNaming
- public class ProcessDailySearchResultsFixture : CoreTest
- {
- private Series _matchingSeries = null;
- private Series _mismatchedSeries = null;
- private Series _nullSeries = null;
-
- [SetUp]
- public void setup()
- {
- _matchingSeries = Builder.CreateNew()
- .With(s => s.SeriesId = 79488)
- .With(s => s.Title = "30 Rock")
- .Build();
-
- _mismatchedSeries = Builder.CreateNew()
- .With(s => s.SeriesId = 12345)
- .With(s => s.Title = "Not 30 Rock")
- .Build();
- }
-
- private void WithMatchingSeries()
- {
- Mocker.GetMock()
- .Setup(s => s.FindSeries(It.IsAny())).Returns(_matchingSeries);
- }
-
- private void WithMisMatchedSeries()
- {
- Mocker.GetMock()
- .Setup(s => s.FindSeries(It.IsAny())).Returns(_mismatchedSeries);
- }
-
- private void WithNullSeries()
- {
- Mocker.GetMock()
- .Setup(s => s.FindSeries(It.IsAny())).Returns(_nullSeries);
- }
-
- private void WithSuccessfulDownload()
- {
- Mocker.GetMock()
- .Setup(s => s.DownloadReport(It.IsAny()))
- .Returns(true);
- }
-
- private void WithFailingDownload()
- {
- Mocker.GetMock()
- .Setup(s => s.DownloadReport(It.IsAny()))
- .Returns(false);
- }
-
- private void WithQualityNeeded()
- {
- Mocker.GetMock()
- .Setup(s => s.IsSatisfiedBy(It.IsAny()))
- .Returns(ReportRejectionType.None);
- }
-
- private void WithQualityNotNeeded()
- {
- Mocker.GetMock()
- .Setup(s => s.IsSatisfiedBy(It.IsAny()))
- .Returns(ReportRejectionType.ExistingQualityIsEqualOrBetter);
- }
-
- [Test]
- public void processSearchResults_higher_quality_should_be_called_first()
- {
- var parseResults = Builder.CreateListOfSize(5)
- .All()
- .With(c => c.AirDate = DateTime.Today)
- .With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
- .Random(1)
- .With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
- .Build();
-
- WithMatchingSeries();
- WithSuccessfulDownload();
-
- Mocker.GetMock()
- .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
- .Returns(ReportRejectionType.None);
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().Contain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.IsSatisfiedBy(It.IsAny()),
- Times.Once());
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Once());
- }
-
- [Test]
- public void processSearchResults_when_quality_is_not_needed_should_check_the_rest()
- {
- var parseResults = Builder.CreateListOfSize(5)
- .All()
- .With(c => c.AirDate = DateTime.Today)
- .With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
- .Build();
-
- WithMatchingSeries();
- WithQualityNotNeeded();
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().NotContain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.IsSatisfiedBy(It.IsAny()),
- Times.Exactly(5));
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Never());
- }
-
- [Test]
- public void processSearchResults_should_skip_if_series_is_null()
- {
- var parseResults = Builder.CreateListOfSize(5)
- .All()
- .With(e => e.AirDate = DateTime.Today)
- .With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
- .Build();
-
- WithNullSeries();
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().NotContain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Never());
- }
-
- [Test]
- public void processSearchResults_should_skip_if_series_is_mismatched()
- {
- var parseResults = Builder.CreateListOfSize(5)
- .All()
- .With(e => e.AirDate = DateTime.Today)
- .With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
- .Build();
-
- WithMisMatchedSeries();
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().NotContain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Never());
- }
-
- [Test]
- public void processSearchResults_should_return_after_successful_download()
- {
- var parseResults = Builder.CreateListOfSize(2)
- .All()
- .With(e => e.AirDate = DateTime.Today)
- .With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
- .Build();
-
- WithMatchingSeries();
- WithQualityNeeded();
- WithSuccessfulDownload();
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().Contain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Once());
- }
-
- [Test]
- public void processSearchResults_should_try_next_if_download_fails()
- {
- var parseResults = Builder.CreateListOfSize(2)
- .All()
- .With(e => e.AirDate = DateTime.Today)
- .With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
- .TheLast(1)
- .With(c => c.Quality = new QualityModel(QualityTypes.SDTV, true))
- .Build();
-
- WithMatchingSeries();
- WithQualityNeeded();
-
- Mocker.GetMock()
- .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.Quality == QualityTypes.SDTV)))
- .Returns(true);
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().Contain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Exactly(2));
- }
-
- [Test]
- public void processSearchResults_should_skip_if_parseResult_does_not_have_airdate()
- {
- var parseResults = Builder.CreateListOfSize(5)
- .All()
- .With(e => e.AirDate = null)
- .With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
- .Build();
-
- WithMatchingSeries();
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().NotContain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Never());
- }
-
- [Test]
- public void processSearchResults_should_skip_if_parseResult_airdate_does_not_match()
- {
- var parseResults = Builder.CreateListOfSize(5)
- .All()
- .With(e => e.AirDate = DateTime.Today.AddDays(10))
- .With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
- .Build();
-
- WithMatchingSeries();
-
- //Act
- var result = Mocker.Resolve().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, DateTime.Today);
-
- //Assert
- result.Should().NotContain(n => n.Success);
-
- Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()),
- Times.Never());
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/SearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/SearchFixture.cs
deleted file mode 100644
index 2f23e3ed8..000000000
--- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/SearchFixture.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.DecisionEngine;
-using NzbDrone.Core.Providers.Indexer;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common;
-
-namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
-{
- public class SearchFixture : CoreTest
- {
- private const string SCENE_NAME = "Scene Name";
- private const int SEASON_NUMBER = 5;
- private const int PARSE_RESULT_COUNT = 10;
-
- private Mock _episodeIndexer1;
- private Mock _episodeIndexer2;
- private Mock _brokenIndexer;
- private Mock _nullIndexer;
-
- private List _indexers;
-
- private Series _series;
- private IList _episodes;
-
- [SetUp]
- public void Setup()
- {
- var parseResults = Builder.CreateListOfSize(PARSE_RESULT_COUNT)
- .Build();
-
- _series = Builder.CreateNew()
- .Build();
-
- _episodes = Builder.CreateListOfSize(1)
- .Build();
-
- BuildIndexers(parseResults);
-
- _indexers = new List { _episodeIndexer1.Object, _episodeIndexer2.Object };
-
- Mocker.GetMock()
- .Setup(c => c.GetEnabledIndexers())
- .Returns(_indexers);
- }
-
- private void BuildIndexers(IList parseResults)
- {
- _episodeIndexer1 = new Mock();
- _episodeIndexer1.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer1.Setup(c => c.FetchSeason(It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer1.Setup(c => c.FetchPartialSeason(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
-
-
- _episodeIndexer2 = new Mock();
- _episodeIndexer2.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer2.Setup(c => c.FetchSeason(It.IsAny(), It.IsAny()))
- .Returns(parseResults);
- _episodeIndexer2.Setup(c => c.FetchPartialSeason(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns(parseResults);
-
- _brokenIndexer = new Mock();
- _brokenIndexer.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Throws(new Exception());
-
- _nullIndexer = new Mock();
- _nullIndexer.Setup(c => c.FetchEpisode(It.IsAny(), It.IsAny(), It.IsAny()))
- .Returns>(null);
- }
-
- private void WithTwoGoodOneBrokenIndexer()
- {
- _indexers = new List { _episodeIndexer1.Object, _brokenIndexer.Object, _episodeIndexer2.Object };
-
- Mocker.GetMock()
- .Setup(c => c.GetEnabledIndexers())
- .Returns(_indexers);
- }
-
- private void WithNullIndexers()
- {
- _indexers = new List { _nullIndexer.Object, _nullIndexer.Object };
-
- Mocker.GetMock()
- .Setup(c => c.GetEnabledIndexers())
- .Returns(_indexers);
- }
-
- private void WithSceneName()
- {
- Mocker.GetMock()
- .Setup(s => s.GetSceneName(_series.SeriesId)).Returns(SCENE_NAME);
- }
-
- private void With30Episodes()
- {
- _episodes = Builder.CreateListOfSize(30)
- .Build();
- }
-
- private void WithNullEpisodes()
- {
- _episodes = null;
- }
-
- private void VerifyFetchEpisode(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchEpisode(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchEpisode(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchEpisodeWithSceneName(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchEpisode(SCENE_NAME, SEASON_NUMBER, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchEpisode(SCENE_NAME, SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchEpisodeBrokenIndexer(Times times)
- {
- _brokenIndexer.Verify(v => v.FetchEpisode(It.IsAny(), SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchPartialSeason(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchPartialSeason(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
-
- _episodeIndexer2.Verify(v => v.FetchPartialSeason(_series.Title, SEASON_NUMBER, It.IsAny())
- , times);
- }
-
- private void VerifyFetchSeason(Times times)
- {
- _episodeIndexer1.Verify(v => v.FetchSeason(_series.Title, SEASON_NUMBER), times);
- _episodeIndexer1.Verify(v => v.FetchSeason(_series.Title, SEASON_NUMBER), times);
- }
-
- [Test]
- public void SeasonSearch_should_skip_daily_series()
- {
- //Setup
- _series.IsDaily = true;
-
- Mocker.GetMock().Setup(s => s.GetSeries(1)).Returns(_series);
-
- //Act
- var result = Mocker.Resolve().SeasonSearch(MockNotification, _series.SeriesId, 1);
-
- //Assert
- result.Should().BeEmpty();
- }
-
- [Test]
- public void PartialSeasonSearch_should_skip_daily_series()
- {
- //Setup
- _series.IsDaily = true;
-
- Mocker.GetMock().Setup(s => s.GetSeries(1)).Returns(_series);
-
- //Act
- var result = Mocker.Resolve().PartialSeasonSearch(MockNotification, _series.SeriesId, 1);
-
- //Assert
- result.Should().BeEmpty();
- }
-
- [Test]
- public void EpisodeSearch_should_skip_if_air_date_is_null_and_is_a_daily_series()
- {
- //Setup
- _series.IsDaily = true;
- var episode = _episodes.First();
- episode.AirDate = null;
- episode.Series = _series;
-
- Mocker.GetMock().Setup(s => s.IsSatisfiedBy(It.IsAny()))
- .Returns(true);
-
- Mocker.GetMock().Setup(s => s.GetEpisode(episode.EpisodeId))
- .Returns(episode);
-
- //Act
- var result = Mocker.Resolve().EpisodeSearch(MockNotification, episode.EpisodeId);
-
- //Assert
- result.Should().BeFalse();
- ExceptionVerification.ExpectedWarns(1);
- }
- }
-}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs
new file mode 100644
index 000000000..b94ab791b
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+using NzbDrone.Core.Repository.Search;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests
+{
+ [TestFixture]
+ public class CheckReportFixture : TestBase
+ {
+ private Series _series;
+ private Episode _episode;
+ private EpisodeParseResult _episodeParseResult;
+ private SearchHistoryItem _searchHistoryItem;
+
+ [SetUp]
+ public void Setup()
+ {
+ _series = Builder
+ .CreateNew()
+ .Build();
+
+ _episode = Builder
+ .CreateNew()
+ .With(e => e.SeriesId = _series.SeriesId)
+ .With(e => e.Series = _series)
+ .Build();
+
+ _episodeParseResult = Builder
+ .CreateNew()
+ .With(p => p.AirDate = _episode.AirDate)
+ .With(p => p.Episodes = new List { _episode })
+ .With(p => p.Series = _series)
+ .Build();
+
+ _searchHistoryItem = new SearchHistoryItem();
+ }
+
+ [Test]
+ public void should_return_WrongEpisode_is_parseResult_doesnt_have_airdate()
+ {
+ _episodeParseResult.AirDate = null;
+
+ Mocker.Resolve()
+ .CheckReport(_series, new {Episode = _episode}, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.WrongEpisode);
+ }
+
+ [Test]
+ public void should_return_WrongEpisode_is_parseResult_airdate_doesnt_match_episode()
+ {
+ _episodeParseResult.AirDate = _episode.AirDate.Value.AddDays(-10);
+
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.WrongEpisode);
+ }
+
+ [Test]
+ public void should_not_return_error_when_airDates_match()
+ {
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.None);
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs
new file mode 100644
index 000000000..35b51b5ba
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+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/EpisodeSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs
new file mode 100644
index 000000000..c0d4f2f38
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+using NzbDrone.Core.Repository.Search;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests
+{
+ [TestFixture]
+ public class CheckReportFixture : TestBase
+ {
+ private Series _series;
+ private Episode _episode;
+ private EpisodeParseResult _episodeParseResult;
+ private SearchHistoryItem _searchHistoryItem;
+
+ [SetUp]
+ public void Setup()
+ {
+ _series = Builder
+ .CreateNew()
+ .Build();
+
+ _episode = Builder
+ .CreateNew()
+ .With(e => e.SeriesId = _series.SeriesId)
+ .With(e => e.Series = _series)
+ .Build();
+
+ _episodeParseResult = Builder
+ .CreateNew()
+ .With(p => p.SeasonNumber = 1)
+ .With(p => p.EpisodeNumbers = new List{ _episode.EpisodeNumber })
+ .With(p => p.Episodes = new List { _episode })
+ .With(p => p.Series = _series)
+ .Build();
+
+ _searchHistoryItem = new SearchHistoryItem();
+ }
+
+ [Test]
+ public void should_return_WrongSeason_when_season_doesnt_match()
+ {
+ _episode.SeasonNumber = 10;
+
+ Mocker.Resolve()
+ .CheckReport(_series, new {Episode = _episode}, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.WrongSeason);
+ }
+
+ [Test]
+ public void should_return_WrongEpisode_when_episode_doesnt_match()
+ {
+ _episode.EpisodeNumber = 10;
+
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.WrongEpisode);
+ }
+
+ [Test]
+ public void should_not_return_error_when_season_and_episode_match()
+ {
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.None);
+ }
+
+ [Test]
+ public void should_return_WrongSeason_when_season_doesnt_match_for_scene_series()
+ {
+ _series.UseSceneNumbering = true;
+ _episode.SceneSeasonNumber = 10;
+ _episode.SeasonNumber = 10;
+ _episode.EpisodeNumber = 10;
+
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.WrongSeason);
+ }
+
+ [Test]
+ public void should_return_WrongEpisode_when_episode_doesnt_match_for_scene_series()
+ {
+ _series.UseSceneNumbering = true;
+ _episode.SceneEpisodeNumber = 10;
+ _episode.SeasonNumber = 10;
+ _episode.EpisodeNumber = 10;
+
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.WrongEpisode);
+ }
+
+ [Test]
+ public void should_not_return_error_when_season_and_episode_match_for_scene_series()
+ {
+ _series.UseSceneNumbering = true;
+ _episode.SceneSeasonNumber = _episode.SeasonNumber;
+ _episode.SceneEpisodeNumber = _episode.EpisodeNumber;
+ _episode.SeasonNumber = 10;
+ _episode.EpisodeNumber = 10;
+
+ Mocker.Resolve()
+ .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
+ .SearchError
+ .Should()
+ .Be(ReportRejectionType.None);
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs
new file mode 100644
index 000000000..5fa687fab
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests
+{
+ [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);
+ }
+
+ [Test]
+ public void should_use_scene_numbering_when_available()
+ {
+ _series.UseSceneNumbering = true;
+ _episode.SceneEpisodeNumber = 5;
+ _episode.SceneSeasonNumber = 10;
+
+ WithValidIndexers();
+
+ Mocker.Resolve()
+ .PerformSearch(_series, new { Episode = _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());
+ }
+
+ [Test]
+ public void should_use_standard_numbering_when_scene_series_set_but_info_is_not_available()
+ {
+ _series.UseSceneNumbering = true;
+ _episode.SceneEpisodeNumber = 0;
+ _episode.SceneSeasonNumber = 0;
+
+ WithValidIndexers();
+
+ Mocker.Resolve()
+ .PerformSearch(_series, new { Episode = _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());
+ }
+
+ [Test]
+ public void should_use_standard_numbering_when_not_scene_series()
+ {
+ _series.UseSceneNumbering = false;
+
+ WithValidIndexers();
+
+ Mocker.Resolve()
+ .PerformSearch(_series, new { Episode = _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/GetSearchTitleFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs
new file mode 100644
index 000000000..245d8357d
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.ProviderTests.SearchTests
+{
+ public class GetSearchTitleFixture : TestBase
+ {
+ private Series _series;
+
+ [SetUp]
+ public void Setup()
+ {
+ _series = Builder
+ .CreateNew()
+ .With(s => s.Title = "Hawaii Five-0")
+ .Build();
+ }
+
+ private void WithSceneMapping()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.GetSceneName(_series.SeriesId))
+ .Returns("Hawaii Five 0 2010");
+ }
+
+ [Test]
+ public void should_return_series_title_when_there_is_no_scene_mapping()
+ {
+ Mocker.Resolve().GetSearchTitle(_series, 5)
+ .Should().Be(_series.Title);
+ }
+
+ [Test]
+ public void should_return_scene_mapping_when_one_exists()
+ {
+ WithSceneMapping();
+
+ Mocker.Resolve().GetSearchTitle(_series, 5)
+ .Should().Be("Hawaii Five 0 2010");
+ }
+
+ [Test]
+ public void should_replace_ampersand_with_and()
+ {
+ _series.Title = "Franklin & Bash";
+
+ Mocker.Resolve().GetSearchTitle(_series, 5)
+ .Should().Be("Franklin and Bash");
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs
new file mode 100644
index 000000000..fd2f3062e
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+using NzbDrone.Core.Repository.Search;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests
+{
+ [TestFixture]
+ public class CheckReportFixture : TestBase
+ {
+ private Series _series;
+ private List _episodes;
+ private EpisodeParseResult _episodeParseResult;
+ private SearchHistoryItem _searchHistoryItem;
+
+ [SetUp]
+ public void Setup()
+ {
+ _series = Builder
+ .CreateNew()
+ .Build();
+
+ _episodes = Builder
+ .CreateListOfSize(10)
+ .All()
+ .With(e => e.SeriesId = _series.SeriesId)
+ .With(e => e.Series = _series)
+ .Build()
+ .ToList();
+
+ _episodeParseResult = Builder
+ .CreateNew()
+ .With(p => p.SeasonNumber = 1)
+ .Build();
+
+ _searchHistoryItem = new SearchHistoryItem();
+ }
+
+ [Test]
+ public void should_return_wrongSeason_when_season_does_not_match()
+ {
+ Mocker.Resolve()
+ .CheckReport(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult, _searchHistoryItem)
+ .SearchError.Should().Be(ReportRejectionType.WrongSeason);
+ }
+
+ [Test]
+ public void should_not_return_error_when_season_matches()
+ {
+ Mocker.Resolve()
+ .CheckReport(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult, _searchHistoryItem)
+ .SearchError.Should().Be(ReportRejectionType.None);
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs
new file mode 100644
index 000000000..6855113d5
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Providers.Search;
+using NzbDrone.Core.Repository;
+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.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs
new file mode 100644
index 000000000..b06a65090
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FizzWare.NBuilder;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Model;
+using NzbDrone.Core.Model.Notification;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Indexer;
+using NzbDrone.Core.Repository;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.ProviderTests.SearchTests
+{
+ public class PerformSearchTestBase : TestBase
+ {
+ protected Series _series;
+ protected Episode _episode;
+ protected List _episodes;
+ protected ProgressNotification notification = new ProgressNotification("Testing");
+
+ protected Mock _indexer1;
+ protected Mock _indexer2;
+ protected List _indexers;
+ protected IList _parseResults;
+
+ [SetUp]
+ public void Setup()
+ {
+ _series = Builder
+ .CreateNew()
+ .Build();
+
+ _episode = Builder
+ .CreateNew()
+ .With(e => e.SeriesId = _series.SeriesId)
+ .With(e => e.Series = _series)
+ .Build();
+
+ _episodes = Builder
+ .CreateListOfSize(10)
+ .All()
+ .With(e => e.SeriesId = _series.SeriesId)
+ .With(e => e.Series = _series)
+ .Build()
+ .ToList();
+
+ _parseResults = Builder
+ .CreateListOfSize(10)
+ .Build();
+
+ _indexer1 = new Mock();
+ _indexer2 = new Mock();
+ _indexers = new List { _indexer1.Object, _indexer2.Object };
+
+ Mocker.GetMock