From 87731d56bfb8607f77bc94583523fa6f9bc0ecb7 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 12 Jul 2013 01:15:23 -0700 Subject: [PATCH] Fixed an issue with parsing full path instead of filename on import This should fix Card #61 --- .../ImportDecisionMakerFixture.cs | 16 ++++++++++++++-- .../EpisodeImport/ImportDecisionMaker.cs | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/ImportDecisionMakerFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/ImportDecisionMakerFixture.cs index 114bd4b15..da2e0355f 100644 --- a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/ImportDecisionMakerFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/ImportDecisionMakerFixture.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using FluentAssertions; using Moq; @@ -59,7 +60,7 @@ public void Setup() _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); _fail3.Setup(c => c.RejectionReason).Returns("_fail3"); - _videoFiles = new List { "The.Office.S03E115.DVDRip.XviD-OSiTV" }; + _videoFiles = new List { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi" }; _series = new Series(); _localEpisode = new LocalEpisode { Series = _series, Path = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi" }; @@ -88,7 +89,6 @@ public void should_call_all_specifications() _pass3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once()); } - [Test] public void should_return_rejected_if_single_specs_fail() { @@ -150,6 +150,18 @@ public void failed_parse_shouldnt_blowup_the_process() ExceptionVerification.ExpectedErrors(3); } + + [Test] + public void should_use_filename_without_extension_when_getting_episodes_from_ParsingService() + { + var expectedFilename = Path.GetFileNameWithoutExtension(_videoFiles.First()); + + GivenSpecifications(_pass1, _pass2, _pass3); + + Subject.GetImportDecisions(_videoFiles, _series); + + Mocker.GetMock().Verify(v => v.GetEpisodes(expectedFilename, _series), Times.Once()); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs index e8b0acd8d..8b4d8bd1b 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using NLog; @@ -42,7 +43,8 @@ private IEnumerable GetDecisions(IEnumerable videoFiles, try { - var parsedEpisode = _parsingService.GetEpisodes(file, series); + var fileWithoutExtension = Path.GetFileNameWithoutExtension(file); + var parsedEpisode = _parsingService.GetEpisodes(Path.GetFileNameWithoutExtension(file), series); if (parsedEpisode != null) {