From 31d472a0a0c2e7f2da50f9a4bfafd4de68ad524a Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Tue, 2 Jul 2013 12:51:16 -0700 Subject: [PATCH] mark parse as invalid if last episode is before first. --- NzbDrone.Core.Test/ParserTests/ParserFixture.cs | 13 +++---------- NzbDrone.Core/Parser/Parser.cs | 9 ++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 320e68aed..321edb16d 100644 --- a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -124,17 +124,10 @@ public void unparsable_path_should_report_the_path() ExceptionVerification.IgnoreWarns(); } - [Test] - [Ignore] - public void unparsable_title_should_report_title() + [TestCase("[DmonHiro] The Severing Crime Edge - Cut 02 - Portrait Of Heresy [BD, 720p] [BE36E9E0]")] + public void unparsable_title_should_log_warn_and_return_null(string title) { - const string TITLE = "SOMETHING 12345"; - - Parser.Parser.ParseTitle(TITLE).Should().BeNull(); - - MockedRestProvider.Verify(c => c.PostData(It.IsAny(), It.Is(r => r.Title == TITLE)), Times.Once()); - - ExceptionVerification.IgnoreWarns(); + Parser.Parser.ParseTitle(title).Should().BeNull(); } //[Timeout(1000)] diff --git a/NzbDrone.Core/Parser/Parser.cs b/NzbDrone.Core/Parser/Parser.cs index d3a483b08..059aa1023 100644 --- a/NzbDrone.Core/Parser/Parser.cs +++ b/NzbDrone.Core/Parser/Parser.cs @@ -184,7 +184,14 @@ private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchColle { var first = Convert.ToInt32(episodeCaptures.First().Value); var last = Convert.ToInt32(episodeCaptures.Last().Value); - result.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToArray(); + + if (first > last) + { + return null; + } + + var count = last - first + 1; + result.EpisodeNumbers = Enumerable.Range(first, count).ToArray(); } else {