From 20e99205f8be83e165a0bb7dd8ed010ef9aa07e9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 8 May 2012 16:05:08 -0700 Subject: [PATCH] Fixed issue with tests. Added test to confirm expected result (Successes != null or empty) --- .../ProcessSearchResultsFixture.cs | 36 +++++++++++++++++++ NzbDrone.Core/Providers/SearchProvider.cs | 7 ++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs index a3ddf644f..d649b0800 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchProviderTests/ProcessSearchResultsFixture.cs @@ -328,5 +328,41 @@ public void processSearchResults_should_try_next_if_download_fails() Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()), Times.Exactly(2)); } + + [Test] + public void processSearchResults_Successes_should_not_be_null_or_empty() + { + var parseResults = Builder.CreateListOfSize(5) + .All() + .With(e => e.SeasonNumber = 1) + .With(e => e.EpisodeNumbers = new List { 1 }) + .With(c => c.Quality = new Quality(QualityTypes.DVD, true)) + .With(c => c.Age = 10) + .Random(1) + .With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true)) + .With(c => c.Age = 100) + .Build(); + + var searchHistory = new SearchHistory(); + + WithMatchingSeries(); + WithSuccessfulDownload(); + + Mocker.GetMock() + .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.QualityType == QualityTypes.Bluray1080p))) + .Returns(ReportRejectionType.None); + + //Act + var result = Mocker.Resolve().ProcessSearchResults(new ProgressNotification("Test"), parseResults, searchHistory, _matchingSeries, 1, 1); + + //Assert + searchHistory.Successes.Should().NotBeNull(); + searchHistory.Successes.Should().NotBeEmpty(); + + Mocker.GetMock().Verify(c => c.IsSatisfiedBy(It.IsAny()), + Times.Once()); + Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()), + Times.Once()); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index ff958d017..65789b7e5 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -52,8 +52,7 @@ public virtual bool SeasonSearch(ProgressNotification notification, int seriesId { SearchTime = DateTime.Now, SeriesId = seriesId, - SeasonNumber = seasonNumber, - Successes = new List() + SeasonNumber = seasonNumber }; var series = _seriesProvider.GetSeries(seriesId); @@ -104,8 +103,7 @@ public virtual List PartialSeasonSearch(ProgressNotification notification, { SearchTime = DateTime.Now, SeriesId = seriesId, - SeasonNumber = seasonNumber, - Successes = new List() + SeasonNumber = seasonNumber }; var series = _seriesProvider.GetSeries(seriesId); @@ -262,6 +260,7 @@ public List PerformSearch(ProgressNotification notification, public List ProcessSearchResults(ProgressNotification notification, IEnumerable reports, SearchHistory searchResult, Series series, int seasonNumber, int? episodeNumber = null) { var items = new List(); + searchResult.Successes = new List(); foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality).ThenBy(c => c.Age)) {