Fixed an issue where GetEpisodesByParseResult would throw object reference when episode list was null

pull/3113/head
Keivan Beigi 13 years ago
parent ea05635fd3
commit ae1a32b874

@ -234,5 +234,31 @@ namespace NzbDrone.Core.Test
db.Fetch<Episode>().Should().HaveCount(2); db.Fetch<Episode>().Should().HaveCount(2);
ep.First().Ignored.Should().BeFalse(); ep.First().Ignored.Should().BeFalse();
} }
[Test]
[Description("GetEpisodeParseResult should return empty list if episode list is null")]
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_null()
{
var mocker = new AutoMoqer();
//Act
var episodes = mocker.Resolve<EpisodeProvider>().GetEpisodesByParseResult(new EpisodeParseResult());
//Assert
episodes.Should().NotBeNull();
episodes.Should().BeEmpty();
}
[Test]
[Description("GetEpisodeParseResult should return empty list if episode list is empty")]
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_empty()
{
var mocker = new AutoMoqer();
//Act
var episodes = mocker.Resolve<EpisodeProvider>().GetEpisodesByParseResult(new EpisodeParseResult{EpisodeNumbers = new List<int>()});
//Assert
episodes.Should().NotBeNull();
episodes.Should().BeEmpty();
}
} }
} }

@ -125,6 +125,9 @@ namespace NzbDrone.Core.Providers
{ {
var result = new List<Episode>(); var result = new List<Episode>();
if (parseResult.EpisodeNumbers == null)
return result;
foreach (var episodeNumber in parseResult.EpisodeNumbers) foreach (var episodeNumber in parseResult.EpisodeNumbers)
{ {
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber); var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
@ -159,7 +162,7 @@ namespace NzbDrone.Core.Providers
} }
else else
{ {
Logger.Debug("Unable to file {0}-S{1:00}E{2:00}", parseResult.Series.Title, parseResult.SeasonNumber, episodeNumber); Logger.Debug("Unable to find {0}-S{1:00}E{2:00}", parseResult.Series.Title, parseResult.SeasonNumber, episodeNumber);
} }
} }

Loading…
Cancel
Save