diff --git a/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs index 126895a23..0a40b2b68 100644 --- a/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs @@ -2,12 +2,12 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.ReferenceData; +using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.IndexerSearchTests { - public class GetSearchTitleFixture : TestBase + public class GetSearchTitleFixture : CoreTest { private Series _series; @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests private void WithSceneMapping() { - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSceneName(_series.Id, -1)) .Returns("Hawaii Five 0 2010"); } @@ -30,8 +30,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests [Test] public void should_return_series_title_when_there_is_no_scene_mapping() { - Mocker.Resolve().GetSearchTitle(_series, 5) - .Should().Be(_series.Title); + Subject.GetSearchTitle(_series, 5).Should().Be(_series.Title); } [Test] @@ -39,19 +38,17 @@ namespace NzbDrone.Core.Test.IndexerSearchTests { WithSceneMapping(); - Mocker.Resolve().GetSearchTitle(_series, 5) - .Should().Be("Hawaii Five 0 2010"); + Subject.GetSearchTitle(_series, 5).Should().Be("Hawaii Five 0 2010"); } [Test] public void should_return_season_scene_name_when_one_exists() { - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSceneName(_series.Id, 5)) .Returns("Hawaii Five 0 2010 - Season 5"); - Mocker.Resolve().GetSearchTitle(_series, 5) - .Should().Be("Hawaii Five 0 2010 - Season 5"); + Subject.GetSearchTitle(_series, 5).Should().Be("Hawaii Five 0 2010 - Season 5"); } [Test] @@ -59,8 +56,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests { WithSceneMapping(); - Mocker.Resolve().GetSearchTitle(_series, 5) - .Should().Be("Hawaii Five 0 2010"); + Subject.GetSearchTitle(_series, 5).Should().Be("Hawaii Five 0 2010"); } [Test] @@ -68,8 +64,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests { _series.Title = "Franklin & Bash"; - Mocker.Resolve().GetSearchTitle(_series, 5) - .Should().Be("Franklin and Bash"); + Subject.GetSearchTitle(_series, 5).Should().Be("Franklin and Bash"); } [TestCase("Betty White's Off Their Rockers", "Betty Whites Off Their Rockers")] @@ -79,12 +74,11 @@ namespace NzbDrone.Core.Test.IndexerSearchTests { _series.Title = input; - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSceneName(_series.Id, -1)) .Returns(""); - Mocker.Resolve().GetSearchTitle(_series, 5) - .Should().Be(expected); + Subject.GetSearchTitle(_series, 5).Should().Be(expected); } } } diff --git a/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs index 4d1ef27a9..c02f4e275 100644 --- a/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearchFixture.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; +using FizzWare.NBuilder; using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Tv; using NzbDrone.Test.Common; +using System.Linq; namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests { @@ -17,9 +19,9 @@ namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests { WithValidIndexers(); - Subject.PerformSearch(_series, new List { _episode }, notification) - .Should() - .HaveCount(20); + Subject.PerformSearch(_series, new List { _episode }, notification) + .Should() + .HaveCount(20); } [Test] @@ -31,7 +33,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests .Should() .HaveCount(0); - ExceptionVerification.ExpectedErrors(4); + ExceptionVerification.ExpectedErrors(2); } [Test] @@ -39,14 +41,29 @@ namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests { WithValidIndexers(); - Subject.PerformSearch(_series, new List { _episode }, notification) - .Should() - .HaveCount(20); + + var episodes = Builder.CreateListOfSize(4) + .All() + .With(c => c.SeasonNumber = 1) + .Build(); + + episodes[0].EpisodeNumber = 1; + episodes[1].EpisodeNumber = 5; + episodes[2].EpisodeNumber = 10; + episodes[3].EpisodeNumber = 15; + + + Subject.PerformSearch(_series, episodes.ToList(), 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()); + + _indexer1.Verify(v => v.FetchPartialSeason(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); + _indexer2.Verify(v => v.FetchPartialSeason(It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(2)); } } } diff --git a/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs index 1f4906d2e..99c36e221 100644 --- a/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/PartialSeasonSearchTests/PartialSeasonSearch_EpisodeMatch.cs @@ -5,13 +5,14 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Model; +using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests { [TestFixture] - public class PartialSeasonSearch_EpisodeMatch : TestBase + public class PartialSeasonSearch_EpisodeMatch : CoreTest { private Series _series; private List _episodes; @@ -42,17 +43,15 @@ namespace NzbDrone.Core.Test.IndexerSearchTests.PartialSeasonSearchTests [Test] public void should_return_wrongSeason_when_season_does_not_match() { - Mocker.Resolve() - .IsEpisodeMatch(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult) + Subject.IsEpisodeMatch(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult) .Should().BeFalse(); } [Test] public void should_not_return_error_when_season_matches() { - Mocker.Resolve() - .IsEpisodeMatch(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult) - .Should().BeFalse(); + Subject.IsEpisodeMatch(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult) + .Should().BeTrue(); } } } diff --git a/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs b/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs index 9bc8104c2..4a4f33f1c 100644 --- a/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs @@ -17,9 +17,9 @@ namespace NzbDrone.Core.Test.IndexerSearchTests { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, + public TestSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider, IIndexerService indexerService, ISceneMappingService sceneMappingService, - DownloadDirector downloadDirector, ISeriesRepository seriesRepository) + IDownloadDirector downloadDirector, ISeriesRepository seriesRepository) : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, downloadDirector) { diff --git a/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs b/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs index 5e062f11f..8027c9f46 100644 --- a/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs +++ b/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs @@ -95,22 +95,22 @@ namespace NzbDrone.Core.Test.Indexers get { return null; } } - protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) + protected override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { throw new NotImplementedException(); } - protected override IList GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) + protected override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) { throw new NotImplementedException(); } - protected override IList GetSeasonSearchUrls(string seriesTitle, int seasonNumber) + protected override IEnumerable GetSeasonSearchUrls(string seriesTitle, int seasonNumber) { throw new NotImplementedException(); } - protected override IList GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) + protected override IEnumerable GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) { throw new NotImplementedException(); } @@ -153,22 +153,22 @@ namespace NzbDrone.Core.Test.Indexers get { return true; } } - protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) + protected override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { throw new NotImplementedException(); } - protected override IList GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) + protected override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) { throw new NotImplementedException(); } - protected override IList GetSeasonSearchUrls(string seriesTitle, int seasonNumber) + protected override IEnumerable GetSeasonSearchUrls(string seriesTitle, int seasonNumber) { throw new NotImplementedException(); } - protected override IList GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) + protected override IEnumerable GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) { throw new NotImplementedException(); } @@ -206,22 +206,22 @@ namespace NzbDrone.Core.Test.Indexers get { return true; } } - protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) + protected override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { throw new NotImplementedException(); } - protected override IList GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) + protected override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) { throw new NotImplementedException(); } - protected override IList GetSeasonSearchUrls(string seriesTitle, int seasonNumber) + protected override IEnumerable GetSeasonSearchUrls(string seriesTitle, int seasonNumber) { throw new NotImplementedException(); } - protected override IList GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) + protected override IEnumerable GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) { throw new NotImplementedException(); } @@ -266,22 +266,22 @@ namespace NzbDrone.Core.Test.Indexers get { return false; } } - protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) + protected override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { throw new NotImplementedException(); } - protected override IList GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) + protected override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) { throw new NotImplementedException(); } - protected override IList GetSeasonSearchUrls(string seriesTitle, int seasonNumber) + protected override IEnumerable GetSeasonSearchUrls(string seriesTitle, int seasonNumber) { throw new NotImplementedException(); } - protected override IList GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) + protected override IEnumerable GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) { throw new NotImplementedException(); } @@ -319,22 +319,22 @@ namespace NzbDrone.Core.Test.Indexers get { return null; } } - protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) + protected override IEnumerable GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { throw new NotImplementedException(); } - protected override IList GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) + protected override IEnumerable GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) { throw new NotImplementedException(); } - protected override IList GetSeasonSearchUrls(string seriesTitle, int seasonNumber) + protected override IEnumerable GetSeasonSearchUrls(string seriesTitle, int seasonNumber) { throw new NotImplementedException(); } - protected override IList GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) + protected override IEnumerable GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) { throw new NotImplementedException(); } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 1f1254a87..efbf51bec 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -411,7 +411,8 @@ - xcopy /s /y "$(SolutionDir)\Libraries\Sqlite\*.*" "$(TargetDir)" + +