From 3f85104d186d698103267e8d240f88bdb406cc4b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 27 Jul 2013 01:02:56 -0700 Subject: [PATCH] Fixed parsing of shows with scene numbering --- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 1 + .../FindEpisodeFixture.cs | 56 +++++++++++++++++++ NzbDrone.Core/Tv/EpisodeRepository.cs | 4 +- 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 43c25a6b9..e89ba8755 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -164,6 +164,7 @@ + diff --git a/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs b/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs new file mode 100644 index 000000000..3f813a3db --- /dev/null +++ b/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/FindEpisodeFixture.cs @@ -0,0 +1,56 @@ +using System; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests +{ + [TestFixture] + public class FindEpisodeFixture : DbTest + { + private Episode _episode; + + [SetUp] + public void Setup() + { + _episode = Builder.CreateNew() + .With(e => e.Id = 0) + .With(e => e.SeriesId = 1) + .With(e => e.SeasonNumber = 1) + .With(e => e.SceneSeasonNumber = 2) + .With(e => e.EpisodeNumber = 3) + .With(e => e.SceneEpisodeNumber = 4) + .Build(); + + _episode = Db.Insert(_episode); + } + + [Test] + public void should_find_episode_by_scene_numbering() + { + Subject.FindEpisodeBySceneNumbering(_episode.SeriesId, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber) + .Id + .Should() + .Be(_episode.Id); + } + + [Test] + public void should_find_episode_by_standard_numbering() + { + Subject.Find(_episode.SeriesId, _episode.SeasonNumber, _episode.EpisodeNumber) + .Id + .Should() + .Be(_episode.Id); + } + + [Test] + public void should_not_find_episode_that_does_not_exist() + { + Subject.Find(_episode.SeriesId, _episode.SeasonNumber + 1, _episode.EpisodeNumber) + .Should() + .BeNull(); + } + } +} diff --git a/NzbDrone.Core/Tv/EpisodeRepository.cs b/NzbDrone.Core/Tv/EpisodeRepository.cs index 9529050ab..280dec96e 100644 --- a/NzbDrone.Core/Tv/EpisodeRepository.cs +++ b/NzbDrone.Core/Tv/EpisodeRepository.cs @@ -90,12 +90,12 @@ public PagingSpec EpisodesWithoutFiles(PagingSpec pagingSpec, public Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber) { - return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber); + return Query.Single(s => s.SeriesId == seriesId && s.SceneSeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber); } public Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber) { - return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber); + return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SceneSeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber); } public List EpisodesWithFiles()