From d2104e189fc98f82ab481572b18a99993a939d58 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 14 Apr 2013 22:27:32 -0700 Subject: [PATCH] fixed some more tests. --- NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs | 6 +++--- .../DiskScanProviderTests/GetVideoFilesFixture.cs | 8 ++++---- .../DiskScanProviderTests/ImportFileFixture.cs | 2 +- .../DropFolderImportServiceFixture.cs | 10 +++++----- NzbDrone.Core/Jobs/Implementations/DiskScanJob.cs | 8 ++++---- NzbDrone.Core/NzbDrone.Core.csproj | 2 +- NzbDrone.Core/Providers/DropfolderImportService.cs | 12 ++++++------ .../{DiskScanProvider.cs => IDiskScanService.cs} | 11 +++++++++-- 8 files changed, 33 insertions(+), 26 deletions(-) rename NzbDrone.Core/Providers/{DiskScanProvider.cs => IDiskScanService.cs} (91%) diff --git a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs index 6af7ed625..4017bc35b 100644 --- a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs @@ -75,11 +75,11 @@ namespace NzbDrone.Core.Test.JobTests .Setup(p => p.All()) .Returns(series); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[0])) .Throws(new InvalidOperationException("Bad Job")); - Mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[1])) .Throws(new InvalidOperationException("Bad Job")); @@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.JobTests Mocker.Resolve().Start(new ProgressNotification("Test"), null); Mocker.VerifyAllMocks(); - Mocker.GetMock().Verify(s => s.Scan(It.IsAny()), Times.Exactly(2)); + Mocker.GetMock().Verify(s => s.Scan(It.IsAny()), Times.Exactly(2)); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs index 69f51be6c..09b9d565b 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Mocker.Resolve().GetVideoFiles(path); + Mocker.Resolve().GetVideoFiles(path); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once()); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never()); @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Mocker.Resolve().GetVideoFiles(path, true); + Mocker.Resolve().GetVideoFiles(path, true); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once()); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never()); @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Mocker.Resolve().GetVideoFiles(path, false); + Mocker.Resolve().GetVideoFiles(path, false); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Never()); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Once()); @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Mocker.Resolve().GetVideoFiles(path).Should().HaveCount(4); + Mocker.Resolve().GetVideoFiles(path).Should().HaveCount(4); } } } diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs index 2cd8f919c..5deb2f0bb 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs @@ -17,7 +17,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { - public class ImportFileFixture : CoreTest + public class ImportFileFixture : CoreTest { diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/DropFolderImportServiceFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/DropFolderImportServiceFixture.cs index 9fb92ddd6..014ae729c 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/DropFolderImportServiceFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/DropFolderImportServiceFixture.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests _fakeEpisodeFile = Builder.CreateNew().Build(); - Mocker.GetMock().Setup(c => c.GetVideoFiles(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.GetVideoFiles(It.IsAny(), It.IsAny())) .Returns(_videoFiles); Mocker.GetMock().Setup(c => c.GetDirectories(It.IsAny())) @@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests [Test] public void all_imported_files_should_be_moved() { - Mocker.GetMock().Setup(c => c.ImportFile(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.ImportFile(It.IsAny(), It.IsAny())) .Returns(_fakeEpisodeFile); Subject.ProcessDropFolder("c:\\drop\\"); @@ -107,7 +107,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests [Test] public void should_not_attempt_move_if_nothing_is_imported() { - Mocker.GetMock().Setup(c => c.ImportFile(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.ImportFile(It.IsAny(), It.IsAny())) .Returns(null); Subject.ProcessDropFolder("c:\\drop\\"); @@ -131,14 +131,14 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests private void VerifyNoImport() { - Mocker.GetMock().Verify(c => c.ImportFile(It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.ImportFile(It.IsAny(), It.IsAny()), Times.Never()); } private void VerifyImport() { - Mocker.GetMock().Verify(c => c.ImportFile(It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.ImportFile(It.IsAny(), It.IsAny()), Times.Once()); } } diff --git a/NzbDrone.Core/Jobs/Implementations/DiskScanJob.cs b/NzbDrone.Core/Jobs/Implementations/DiskScanJob.cs index 47294f5c1..addc282b4 100644 --- a/NzbDrone.Core/Jobs/Implementations/DiskScanJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/DiskScanJob.cs @@ -12,15 +12,15 @@ namespace NzbDrone.Core.Jobs.Implementations { public class DiskScanJob : IJob { - private readonly DiskScanProvider _diskScanProvider; + private readonly IDiskScanService _diskScanService; private readonly IConfigService _configService; private readonly ISeriesRepository _seriesRepository; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public DiskScanJob(DiskScanProvider diskScanProvider, + public DiskScanJob(IDiskScanService diskScanService, IConfigService configService, ISeriesRepository seriesRepository) { - _diskScanProvider = diskScanProvider; + _diskScanService = diskScanService; _configService = configService; _seriesRepository = seriesRepository; } @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Jobs.Implementations try { notification.CurrentMessage = string.Format("Scanning disk for '{0}'", series.Title); - _diskScanProvider.Scan(series); + _diskScanService.Scan(series); notification.CurrentMessage = string.Format("Disk Scan completed for '{0}'", series.Title); } catch (Exception e) diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index dec99946a..21554709d 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -415,7 +415,7 @@ Code - + Code diff --git a/NzbDrone.Core/Providers/DropfolderImportService.cs b/NzbDrone.Core/Providers/DropfolderImportService.cs index c453baf2a..e490c4e20 100644 --- a/NzbDrone.Core/Providers/DropfolderImportService.cs +++ b/NzbDrone.Core/Providers/DropfolderImportService.cs @@ -16,21 +16,21 @@ namespace NzbDrone.Core.Providers public class DropFolderImportService : IDropFolderImportService { private readonly DiskProvider _diskProvider; - private readonly DiskScanProvider _diskScanProvider; + private readonly IDiskScanService _diskScanService; private readonly ISeriesService _seriesService; private readonly IMoveEpisodeFiles _episodeFileMover; private readonly IParsingService _parsingService; private readonly Logger _logger; public DropFolderImportService(DiskProvider diskProvider, - DiskScanProvider diskScanProvider, + IDiskScanService diskScanService, ISeriesService seriesService, IMoveEpisodeFiles episodeFileMover, IParsingService parsingService, Logger logger) { _diskProvider = diskProvider; - _diskScanProvider = diskScanProvider; + _diskScanService = diskScanService; _seriesService = seriesService; _episodeFileMover = episodeFileMover; _parsingService = parsingService; @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Providers } } - foreach (var videoFile in _diskScanProvider.GetVideoFiles(dropFolder, false)) + foreach (var videoFile in _diskScanService.GetVideoFiles(dropFolder, false)) { try { @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Providers return; } - var files = _diskScanProvider.GetVideoFiles(subfolderInfo.FullName); + var files = _diskScanService.GetVideoFiles(subfolderInfo.FullName); foreach (var file in files) { @@ -109,7 +109,7 @@ namespace NzbDrone.Core.Providers return; } - var episodeFile = _diskScanProvider.ImportFile(series, videoFile); + var episodeFile = _diskScanService.ImportFile(series, videoFile); if (episodeFile != null) { diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/IDiskScanService.cs similarity index 91% rename from NzbDrone.Core/Providers/DiskScanProvider.cs rename to NzbDrone.Core/Providers/IDiskScanService.cs index b65501ec6..d9446554c 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/IDiskScanService.cs @@ -10,7 +10,14 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Providers { - public class DiskScanProvider + public interface IDiskScanService + { + void Scan(Series series); + EpisodeFile ImportFile(Series series, string filePath); + string[] GetVideoFiles(string path, bool allDirectories = true); + } + + public class DiskScanService : IDiskScanService { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly string[] MediaExtensions = new[] { ".mkv", ".avi", ".wmv", ".mp4", ".mpg", ".mpeg", ".xvid", ".flv", ".mov", ".rm", ".rmvb", ".divx", ".dvr-ms", ".ts", ".ogm", ".m4v", ".strm" }; @@ -20,7 +27,7 @@ namespace NzbDrone.Core.Providers private readonly IVideoFileInfoReader _videoFileInfoReader; private readonly IParsingService _parsingService; - public DiskScanProvider(DiskProvider diskProvider, ICleanGhostFiles ghostFileCleaner, IMediaFileService mediaFileService, IVideoFileInfoReader videoFileInfoReader, + public DiskScanService(DiskProvider diskProvider, ICleanGhostFiles ghostFileCleaner, IMediaFileService mediaFileService, IVideoFileInfoReader videoFileInfoReader, IParsingService parsingService) { _diskProvider = diskProvider;