2013-01-13 08:24:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-11-18 02:36:53 +00:00
|
|
|
|
using System.Linq;
|
2013-01-13 08:24:48 +00:00
|
|
|
|
using System.Text;
|
2011-11-18 02:36:53 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2013-02-24 19:18:48 +00:00
|
|
|
|
using NzbDrone.Core.Download;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2011-11-18 02:36:53 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-02-19 02:19:38 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2013-01-13 08:24:48 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Search;
|
2011-11-18 02:36:53 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2012-04-23 06:31:11 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Search;
|
2013-01-13 08:24:48 +00:00
|
|
|
|
using NzbDrone.Test.Common;
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public class ProcessResultsFixture : TestBase
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
2013-01-13 08:24:48 +00:00
|
|
|
|
private Series _matchingSeries;
|
|
|
|
|
private Series _mismatchedSeries;
|
2011-11-18 02:36:53 +00:00
|
|
|
|
private Series _nullSeries = null;
|
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
private SearchHistory _searchHistory;
|
|
|
|
|
private ProgressNotification _notification;
|
|
|
|
|
|
|
|
|
|
private IList<Episode> _episodes;
|
|
|
|
|
|
2011-11-18 02:36:53 +00:00
|
|
|
|
[SetUp]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void Setup()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
|
|
|
|
_matchingSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 79488)
|
|
|
|
|
.With(s => s.Title = "30 Rock")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_mismatchedSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 12345)
|
|
|
|
|
.With(s => s.Title = "Not 30 Rock")
|
|
|
|
|
.Build();
|
2013-01-13 08:24:48 +00:00
|
|
|
|
|
|
|
|
|
_searchHistory = new SearchHistory();
|
|
|
|
|
_notification = new ProgressNotification("Test");
|
|
|
|
|
|
|
|
|
|
_episodes = Builder<Episode>
|
|
|
|
|
.CreateListOfSize(1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
|
|
|
|
.Returns(_episodes);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithMatchingSeries()
|
|
|
|
|
{
|
2013-02-19 06:56:02 +00:00
|
|
|
|
Mocker.GetMock<ISeriesRepository>()
|
2013-02-20 02:05:15 +00:00
|
|
|
|
.Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(_matchingSeries);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithMisMatchedSeries()
|
|
|
|
|
{
|
2013-02-19 06:56:02 +00:00
|
|
|
|
Mocker.GetMock<ISeriesRepository>()
|
2013-02-20 02:05:15 +00:00
|
|
|
|
.Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(_mismatchedSeries);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithNullSeries()
|
|
|
|
|
{
|
2013-02-19 06:56:02 +00:00
|
|
|
|
Mocker.GetMock<ISeriesRepository>()
|
2013-02-20 02:05:15 +00:00
|
|
|
|
.Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(_nullSeries);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithSuccessfulDownload()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
|
|
|
|
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithFailingDownload()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
|
|
|
|
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithQualityNeeded()
|
|
|
|
|
{
|
2012-02-07 05:08:07 +00:00
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>()
|
|
|
|
|
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
2012-04-20 06:42:13 +00:00
|
|
|
|
.Returns(ReportRejectionType.None);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithQualityNotNeeded()
|
|
|
|
|
{
|
2012-02-07 05:08:07 +00:00
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>()
|
|
|
|
|
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
2012-04-20 06:42:13 +00:00
|
|
|
|
.Returns(ReportRejectionType.ExistingQualityIsEqualOrBetter);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_process_higher_quality_results_first()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
2013-01-13 08:24:48 +00:00
|
|
|
|
WithMatchingSeries();
|
|
|
|
|
WithSuccessfulDownload();
|
|
|
|
|
|
2011-11-18 02:36:53 +00:00
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
|
2012-02-18 19:20:18 +00:00
|
|
|
|
.With(c => c.Age = 10)
|
2011-11-18 02:36:53 +00:00
|
|
|
|
.Random(1)
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
|
2012-02-18 19:20:18 +00:00
|
|
|
|
.With(c => c.Age = 100)
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-07 05:08:07 +00:00
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>()
|
2012-10-14 00:36:16 +00:00
|
|
|
|
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
|
2012-04-20 06:42:13 +00:00
|
|
|
|
.Returns(ReportRejectionType.None);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().Contain(s => s.Success);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2012-02-07 05:08:07 +00:00
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
2011-11-18 02:36:53 +00:00
|
|
|
|
Times.Once());
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 19:20:18 +00:00
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_process_newer_reports_first()
|
2012-02-18 19:20:18 +00:00
|
|
|
|
{
|
2013-01-13 08:24:48 +00:00
|
|
|
|
WithMatchingSeries();
|
|
|
|
|
WithSuccessfulDownload();
|
|
|
|
|
|
2012-02-18 19:20:18 +00:00
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
|
2012-02-18 19:20:18 +00:00
|
|
|
|
.With(c => c.Age = 300)
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2012-02-18 19:20:18 +00:00
|
|
|
|
|
|
|
|
|
parseResults[2].Age = 100;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>()
|
2012-04-20 06:42:13 +00:00
|
|
|
|
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(ReportRejectionType.None);
|
2012-02-18 19:20:18 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2012-02-18 19:20:18 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().Contain(s => s.Success);
|
2012-02-18 19:20:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Age != 100)), Times.Never());
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Age == 100)), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-18 02:36:53 +00:00
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_check_other_reports_when_quality_is_not_wanted()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
2013-01-13 08:24:48 +00:00
|
|
|
|
WithMatchingSeries();
|
|
|
|
|
WithQualityNotNeeded();
|
|
|
|
|
|
2011-11-18 02:36:53 +00:00
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().NotContain(s => s.Success);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
2012-02-07 05:08:07 +00:00
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
2011-11-18 02:36:53 +00:00
|
|
|
|
Times.Exactly(5));
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_should_skip_if_series_is_not_watched()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2013-01-01 03:45:57 +00:00
|
|
|
|
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
WithNullSeries();
|
|
|
|
|
|
|
|
|
|
//Act
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().NotContain(s => s.Success);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_skip_if_series_does_not_match_searched_series()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2013-01-01 03:45:57 +00:00
|
|
|
|
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
WithMisMatchedSeries();
|
|
|
|
|
|
|
|
|
|
//Act
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().NotContain(s => s.Success);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_skip_if_episode_was_already_downloaded()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(2)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 5 })
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
|
2011-11-18 02:36:53 +00:00
|
|
|
|
.TheLast(1)
|
2012-02-18 19:20:18 +00:00
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1, 2, 3, 4, 5 })
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
WithMatchingSeries();
|
|
|
|
|
WithQualityNeeded();
|
|
|
|
|
WithSuccessfulDownload();
|
|
|
|
|
|
|
|
|
|
//Act
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().Contain(s => s.Success);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_try_next_report_if_download_fails()
|
2011-11-18 02:36:53 +00:00
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(2)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
|
2011-11-18 02:36:53 +00:00
|
|
|
|
.TheLast(1)
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.SDTV, true))
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
WithMatchingSeries();
|
|
|
|
|
WithQualityNeeded();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
2012-10-14 00:36:16 +00:00
|
|
|
|
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.DVD)))
|
2011-11-18 02:36:53 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
2012-10-14 00:36:16 +00:00
|
|
|
|
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.SDTV)))
|
2011-11-18 02:36:53 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
|
|
|
result.SearchHistoryItems.Should().Contain(s => s.Success);
|
2011-11-18 02:36:53 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Exactly(2));
|
|
|
|
|
}
|
2012-05-08 23:05:08 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
2013-01-13 08:24:48 +00:00
|
|
|
|
public void should_return_valid_successes_when_one_or_more_downloaded()
|
2012-05-08 23:05:08 +00:00
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
|
2012-05-08 23:05:08 +00:00
|
|
|
|
.With(c => c.Age = 10)
|
|
|
|
|
.Random(1)
|
2012-10-13 21:15:21 +00:00
|
|
|
|
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
|
2012-05-08 23:05:08 +00:00
|
|
|
|
.With(c => c.Age = 100)
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2012-05-08 23:05:08 +00:00
|
|
|
|
|
|
|
|
|
WithMatchingSeries();
|
|
|
|
|
WithSuccessfulDownload();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>()
|
2012-10-14 00:36:16 +00:00
|
|
|
|
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
|
2012-05-08 23:05:08 +00:00
|
|
|
|
.Returns(ReportRejectionType.None);
|
|
|
|
|
|
|
|
|
|
//Act
|
2013-01-13 08:24:48 +00:00
|
|
|
|
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
2012-05-08 23:05:08 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2013-01-13 08:24:48 +00:00
|
|
|
|
result.Successes.Should().NotBeNull();
|
|
|
|
|
result.Successes.Should().NotBeEmpty();
|
2012-05-08 23:05:08 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Once());
|
|
|
|
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
2011-11-18 02:36:53 +00:00
|
|
|
|
}
|
2013-01-13 08:24:48 +00:00
|
|
|
|
}
|