GetEpisodesByParseResult will return multiple episode names when multiple episodes are found.

pull/4/head
Mark McDowall 13 years ago
parent dba5a1a236
commit f3fbcec8cb

@ -127,7 +127,6 @@ namespace NzbDrone.Core.Test.ProviderTests
ep.Should().HaveCount(2);
Db.Fetch<Episode>().Should().HaveCount(2);
ep.First().ShouldHave().AllPropertiesBut(e => e.Series);
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
}
[Test]
@ -313,5 +312,77 @@ namespace NzbDrone.Core.Test.ProviderTests
episodes.Should().BeEmpty();
Db.Fetch<Episode>().Should().BeEmpty();
}
[Test]
public void GetEpisodeParseResult_should_return_multiple_titles_for_multiple_episodes()
{
WithRealDb();
var fakeEpisode = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = 1)
.With(e => e.SeasonNumber = 2)
.With(e => e.EpisodeNumber = 10)
.With(e => e.Title = "Title1")
.Build();
var fakeEpisode2 = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = 1)
.With(e => e.SeasonNumber = 2)
.With(e => e.EpisodeNumber = 11)
.With(e => e.Title = "Title2")
.Build();
var fakeSeries = Builder<Series>.CreateNew().Build();
Db.Insert(fakeEpisode);
Db.Insert(fakeEpisode2);
Db.Insert(fakeSeries);
var parseResult = new EpisodeParseResult
{
Series = fakeSeries,
SeasonNumber = 2,
EpisodeNumbers = new List<int> { 10, 11 }
};
var ep = Mocker.Resolve<EpisodeProvider>().GetEpisodesByParseResult(parseResult);
ep.Should().HaveCount(2);
Db.Fetch<Episode>().Should().HaveCount(2);
ep.First().ShouldHave().AllPropertiesBut(e => e.Series);
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title + " + " + fakeEpisode2.Title);
}
[Test]
public void GetEpisodeParseResult_should_return_single_title_for_single_episode()
{
WithRealDb();
var fakeEpisode = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = 1)
.With(e => e.SeasonNumber = 2)
.With(e => e.EpisodeNumber = 10)
.With(e => e.Title = "Title1")
.Build();
var fakeSeries = Builder<Series>.CreateNew().Build();
Db.Insert(fakeEpisode);
Db.Insert(fakeSeries);
var parseResult = new EpisodeParseResult
{
Series = fakeSeries,
SeasonNumber = 2,
EpisodeNumbers = new List<int> { 10 }
};
var ep = Mocker.Resolve<EpisodeProvider>().GetEpisodesByParseResult(parseResult);
ep.Should().HaveCount(1);
Db.Fetch<Episode>().Should().HaveCount(1);
ep.First().ShouldHave().AllPropertiesBut(e => e.Series);
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
}
}
}

@ -161,6 +161,7 @@ namespace NzbDrone.Core.Providers
if (episodeInfo != null)
{
result.Add(episodeInfo);
parseResult.EpisodeTitle = episodeInfo.Title;
}
return result;
@ -199,7 +200,8 @@ namespace NzbDrone.Core.Providers
if (episodeInfo != null)
{
result.Add(episodeInfo);
parseResult.EpisodeTitle = episodeInfo.Title;
parseResult.EpisodeTitle += String.Format(" + {0}", episodeInfo.Title);
parseResult.EpisodeTitle = parseResult.EpisodeTitle.Trim('+', ' ');
}
else
{

Loading…
Cancel
Save