1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 01:27:00 +00:00

New: When searching for episodes, newer reports are given priority over older reports of equal quality.

This commit is contained in:
kay.one 2012-02-18 11:20:18 -08:00
parent 5bf56ffca3
commit ac84d76ef9
2 changed files with 35 additions and 2 deletions

View file

@ -91,8 +91,10 @@ public void processSearchResults_higher_quality_should_be_called_first()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 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();
WithMatchingSeries();
@ -115,6 +117,37 @@ public void processSearchResults_higher_quality_should_be_called_first()
Times.Once());
}
[Test]
public void processSearchResults_newer_report_should_be_called_first()
{
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 300)
.Build();
parseResults[2].Age = 100;
WithMatchingSeries();
WithSuccessfulDownload();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
//Act
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, 1, 1);
//Assert
result.Should().HaveCount(1);
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());
}
[Test]
public void processSearchResults_when_quality_is_not_needed_should_check_the_rest()
{
@ -233,7 +266,7 @@ public void processSearchResults_should_skip_if_any_episodeNumber_was_already_ad
.With(e => e.EpisodeNumbers = new List<int> { 5 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.TheLast(1)
.With(e => e.EpisodeNumbers = new List<int> { 1,2,3,4,5 })
.With(e => e.EpisodeNumbers = new List<int> { 1, 2, 3, 4, 5 })
.Build();
WithMatchingSeries();

View file

@ -231,7 +231,7 @@ public List<int> ProcessSearchResults(ProgressNotification notification, IEnumer
{
var successes = new List<int>();
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality))
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality).ThenBy(c => c.Age))
{
try
{