From eddfe67eb193e7e004e12679c81ebb89c92d27ef Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 23 Feb 2014 16:02:28 +0100 Subject: [PATCH] Added test to verify 'like' clause and fixed issue. --- .../EpisodesWhereCutoffUnmetFixture.cs | 13 +++++++++---- src/NzbDrone.Core/Tv/EpisodeRepository.cs | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs index cc46bad8b..5a3f2e1fc 100644 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs @@ -28,8 +28,9 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests Cutoff = Quality.WEBDL480p, Items = new List { - new QualityProfileItem { Allowed = true, Quality = Quality.SDTV }, - new QualityProfileItem { Allowed = true, Quality = Quality.WEBDL480p } + new QualityProfileItem { Allowed = true, Quality = Quality.SDTV }, + new QualityProfileItem { Allowed = true, Quality = Quality.WEBDL480p }, + new QualityProfileItem { Allowed = true, Quality = Quality.RAWHD } } }; @@ -64,16 +65,18 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests { new QualitiesBelowCutoff(qualityProfile.Id, new[] {Quality.SDTV.Id}) }; - + var qualityMet = new EpisodeFile { Path = "a", Quality = new QualityModel { Quality = Quality.WEBDL480p } }; var qualityUnmet = new EpisodeFile { Path = "b", Quality = new QualityModel { Quality = Quality.SDTV } }; + var qualityRawHD = new EpisodeFile { Path = "c", Quality = new QualityModel { Quality = Quality.RAWHD } }; MediaFileRepository fileRepository = Mocker.Resolve(); qualityMet = fileRepository.Insert(qualityMet); qualityUnmet = fileRepository.Insert(qualityUnmet); + qualityRawHD = fileRepository.Insert(qualityRawHD); - var monitoredSeriesEpisodes = Builder.CreateListOfSize(3) + var monitoredSeriesEpisodes = Builder.CreateListOfSize(4) .All() .With(e => e.Id = 0) .With(e => e.SeriesId = _monitoredSeries.Id) @@ -83,6 +86,8 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests .TheFirst(1) .With(e => e.Monitored = false) .With(e => e.EpisodeFileId = qualityMet.Id) + .TheNext(1) + .With(e => e.EpisodeFileId = qualityRawHD.Id) .TheLast(1) .With(e => e.SeasonNumber = 0) .Build(); diff --git a/src/NzbDrone.Core/Tv/EpisodeRepository.cs b/src/NzbDrone.Core/Tv/EpisodeRepository.cs index d3d95fc8c..3324ec189 100644 --- a/src/NzbDrone.Core/Tv/EpisodeRepository.cs +++ b/src/NzbDrone.Core/Tv/EpisodeRepository.cs @@ -194,7 +194,7 @@ namespace NzbDrone.Core.Tv { foreach (var belowCutoff in profile.QualityIds) { - clauses.Add(String.Format("([t1].[QualityProfileId] = {0} AND [t2].[Quality] LIKE '%_quality_:%{1}%')", profile.ProfileId, belowCutoff)); + clauses.Add(String.Format("([t1].[QualityProfileId] = {0} AND [t2].[Quality] LIKE '%_quality_: {1},%')", profile.ProfileId, belowCutoff)); } }