mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 10:32:35 +01:00
Fixed issue with tests.
Added test to confirm expected result (Successes != null or empty)
This commit is contained in:
parent
c59f1a537d
commit
20e99205f8
@ -328,5 +328,41 @@ public void processSearchResults_should_try_next_if_download_fails()
|
|||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
||||||
Times.Exactly(2));
|
Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void processSearchResults_Successes_should_not_be_null_or_empty()
|
||||||
|
{
|
||||||
|
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.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<AllowedDownloadSpecification>()
|
||||||
|
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
|
||||||
|
.Returns(ReportRejectionType.None);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, searchHistory, _matchingSeries, 1, 1);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
searchHistory.Successes.Should().NotBeNull();
|
||||||
|
searchHistory.Successes.Should().NotBeEmpty();
|
||||||
|
|
||||||
|
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
||||||
|
Times.Once());
|
||||||
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
||||||
|
Times.Once());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,8 +52,7 @@ public virtual bool SeasonSearch(ProgressNotification notification, int seriesId
|
|||||||
{
|
{
|
||||||
SearchTime = DateTime.Now,
|
SearchTime = DateTime.Now,
|
||||||
SeriesId = seriesId,
|
SeriesId = seriesId,
|
||||||
SeasonNumber = seasonNumber,
|
SeasonNumber = seasonNumber
|
||||||
Successes = new List<int>()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var series = _seriesProvider.GetSeries(seriesId);
|
var series = _seriesProvider.GetSeries(seriesId);
|
||||||
@ -104,8 +103,7 @@ public virtual List<int> PartialSeasonSearch(ProgressNotification notification,
|
|||||||
{
|
{
|
||||||
SearchTime = DateTime.Now,
|
SearchTime = DateTime.Now,
|
||||||
SeriesId = seriesId,
|
SeriesId = seriesId,
|
||||||
SeasonNumber = seasonNumber,
|
SeasonNumber = seasonNumber
|
||||||
Successes = new List<int>()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var series = _seriesProvider.GetSeries(seriesId);
|
var series = _seriesProvider.GetSeries(seriesId);
|
||||||
@ -262,6 +260,7 @@ public List<EpisodeParseResult> PerformSearch(ProgressNotification notification,
|
|||||||
public List<SearchHistoryItem> ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, SearchHistory searchResult, Series series, int seasonNumber, int? episodeNumber = null)
|
public List<SearchHistoryItem> ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, SearchHistory searchResult, Series series, int seasonNumber, int? episodeNumber = null)
|
||||||
{
|
{
|
||||||
var items = new List<SearchHistoryItem>();
|
var items = new List<SearchHistoryItem>();
|
||||||
|
searchResult.Successes = new List<int>();
|
||||||
|
|
||||||
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality).ThenBy(c => c.Age))
|
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality).ThenBy(c => c.Age))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user