From 4c8b1d960483f2845d6879b01abdecec207200cb Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 5 Jun 2011 12:15:46 -0700 Subject: [PATCH] Fixed bug in history check. --- NzbDrone.Core.Test/HistoryProviderTest.cs | 4 +++- NzbDrone.Core/Providers/HistoryProvider.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Core.Test/HistoryProviderTest.cs b/NzbDrone.Core.Test/HistoryProviderTest.cs index 256e926ad..18c6df726 100644 --- a/NzbDrone.Core.Test/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/HistoryProviderTest.cs @@ -79,7 +79,8 @@ namespace NzbDrone.Core.Test var repo = MockLib.GetEmptyRepository(); - var history = Builder.CreateNew().Build(); + var history = Builder.CreateNew() + .With(h => h.Quality = QualityTypes.Bluray720p).Build(); repo.Add(history); mocker.SetConstant(repo); @@ -88,6 +89,7 @@ namespace NzbDrone.Core.Test //Assert Assert.IsNotNull(result); + result.QualityType.Should().Be(QualityTypes.Bluray720p); } [Test] diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index 189de8d84..c1d2a642e 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -49,8 +49,8 @@ namespace NzbDrone.Core.Providers public virtual Quality GetBestQualityInHistory(long episodeId) { - var history = AllItems().Where(c => c.EpisodeId == episodeId).Select(d => new Quality() { QualityType = d.Quality, Proper = d.IsProper }).ToList(); - history.Sort(); + var history = AllItems().Where(c => c.EpisodeId == episodeId).ToList().Select(d => new Quality(d.Quality, d.IsProper)); + history.OrderBy(q => q); return history.FirstOrDefault(); }