mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
fixed some more tests.
This commit is contained in:
parent
6675a841d7
commit
d2104e189f
@ -75,11 +75,11 @@ public void failed_scan_should_not_terminated_job()
|
||||
.Setup(p => p.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
Mocker.GetMock<IDiskScanService>()
|
||||
.Setup(s => s.Scan(series[0]))
|
||||
.Throws(new InvalidOperationException("Bad Job"));
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
Mocker.GetMock<IDiskScanService>()
|
||||
.Setup(s => s.Scan(series[1]))
|
||||
.Throws(new InvalidOperationException("Bad Job"));
|
||||
|
||||
@ -105,7 +105,7 @@ public void job_with_no_target_should_scan_series_with_episodes()
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), null);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<DiskScanProvider>().Verify(s => s.Scan(It.IsAny<Series>()), Times.Exactly(2));
|
||||
Mocker.GetMock<IDiskScanService>().Verify(s => s.Scan(It.IsAny<Series>()), Times.Exactly(2));
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ public void should_check_all_directories()
|
||||
{
|
||||
var path = @"C:\Test\";
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().GetVideoFiles(path);
|
||||
Mocker.Resolve<IDiskScanService>().GetVideoFiles(path);
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once());
|
||||
Mocker.GetMock<DiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never());
|
||||
@ -55,7 +55,7 @@ public void should_check_all_directories_when_allDirectories_is_true()
|
||||
{
|
||||
var path = @"C:\Test\";
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().GetVideoFiles(path, true);
|
||||
Mocker.Resolve<IDiskScanService>().GetVideoFiles(path, true);
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once());
|
||||
Mocker.GetMock<DiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never());
|
||||
@ -66,7 +66,7 @@ public void should_check_top_level_directory_only_when_allDirectories_is_false()
|
||||
{
|
||||
var path = @"C:\Test\";
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().GetVideoFiles(path, false);
|
||||
Mocker.Resolve<IDiskScanService>().GetVideoFiles(path, false);
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Never());
|
||||
Mocker.GetMock<DiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Once());
|
||||
@ -77,7 +77,7 @@ public void should_return_video_files_only()
|
||||
{
|
||||
var path = @"C:\Test\";
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().GetVideoFiles(path).Should().HaveCount(4);
|
||||
Mocker.Resolve<IDiskScanService>().GetVideoFiles(path).Should().HaveCount(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
|
||||
public class ImportFileFixture : CoreTest<DiskScanProvider>
|
||||
public class ImportFileFixture : CoreTest<DiskScanService>
|
||||
{
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ public void Setup()
|
||||
_fakeEpisodeFile = Builder<EpisodeFile>.CreateNew().Build();
|
||||
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(c => c.GetVideoFiles(It.IsAny<string>(), It.IsAny<bool>()))
|
||||
Mocker.GetMock<IDiskScanService>().Setup(c => c.GetVideoFiles(It.IsAny<string>(), It.IsAny<bool>()))
|
||||
.Returns(_videoFiles);
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Setup(c => c.GetDirectories(It.IsAny<string>()))
|
||||
@ -96,7 +96,7 @@ public void should_search_for_series_using_file_name()
|
||||
[Test]
|
||||
public void all_imported_files_should_be_moved()
|
||||
{
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()))
|
||||
Mocker.GetMock<IDiskScanService>().Setup(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()))
|
||||
.Returns(_fakeEpisodeFile);
|
||||
|
||||
Subject.ProcessDropFolder("c:\\drop\\");
|
||||
@ -107,7 +107,7 @@ public void all_imported_files_should_be_moved()
|
||||
[Test]
|
||||
public void should_not_attempt_move_if_nothing_is_imported()
|
||||
{
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()))
|
||||
Mocker.GetMock<IDiskScanService>().Setup(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()))
|
||||
.Returns<EpisodeFile>(null);
|
||||
|
||||
Subject.ProcessDropFolder("c:\\drop\\");
|
||||
@ -131,14 +131,14 @@ public void should_skip_if_folder_is_in_use_by_another_process()
|
||||
|
||||
private void VerifyNoImport()
|
||||
{
|
||||
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()),
|
||||
Mocker.GetMock<IDiskScanService>().Verify(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
|
||||
private void VerifyImport()
|
||||
{
|
||||
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()),
|
||||
Mocker.GetMock<IDiskScanService>().Verify(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<string>()),
|
||||
Times.Once());
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
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)
|
||||
|
@ -415,7 +415,7 @@
|
||||
<Compile Include="DecisionEngine\Specifications\RetentionSpecification.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\DiskScanProvider.cs">
|
||||
<Compile Include="Providers\IDiskScanService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Download\Clients\BlackholeProvider.cs">
|
||||
|
@ -16,21 +16,21 @@ public interface IDropFolderImportService
|
||||
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 @@ public virtual void ProcessDropFolder(string dropFolder)
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var videoFile in _diskScanProvider.GetVideoFiles(dropFolder, false))
|
||||
foreach (var videoFile in _diskScanService.GetVideoFiles(dropFolder, false))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -86,7 +86,7 @@ public void ProcessSubFolder(DirectoryInfo subfolderInfo)
|
||||
return;
|
||||
}
|
||||
|
||||
var files = _diskScanProvider.GetVideoFiles(subfolderInfo.FullName);
|
||||
var files = _diskScanService.GetVideoFiles(subfolderInfo.FullName);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
@ -109,7 +109,7 @@ public void ProcessVideoFile(string videoFile, Series series)
|
||||
return;
|
||||
}
|
||||
|
||||
var episodeFile = _diskScanProvider.ImportFile(series, videoFile);
|
||||
var episodeFile = _diskScanService.ImportFile(series, videoFile);
|
||||
|
||||
if (episodeFile != null)
|
||||
{
|
||||
|
@ -10,7 +10,14 @@
|
||||
|
||||
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 @@ public class DiskScanProvider
|
||||
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;
|
Loading…
Reference in New Issue
Block a user