mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
fixed some more tests.
This commit is contained in:
parent
6675a841d7
commit
d2104e189f
@ -75,11 +75,11 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
.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 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
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 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
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 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
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 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
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 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
var path = @"C:\Test\";
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().GetVideoFiles(path).Should().HaveCount(4);
|
||||
Mocker.Resolve<IDiskScanService>().GetVideoFiles(path).Should().HaveCount(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ using NzbDrone.Core.Test.Framework;
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
|
||||
public class ImportFileFixture : CoreTest<DiskScanProvider>
|
||||
public class ImportFileFixture : CoreTest<DiskScanService>
|
||||
{
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
_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 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
[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 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
[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 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
|
||||
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 @@ 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)
|
||||
|
@ -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 @@ 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)
|
||||
{
|
||||
|
@ -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;
|
Loading…
Reference in New Issue
Block a user