@ -4,6 +4,7 @@ using FizzWare.NBuilder;
using Moq ;
using NUnit.Framework ;
using NzbDrone.Common ;
using NzbDrone.Core.Configuration ;
using NzbDrone.Core.MediaFiles ;
using NzbDrone.Core.Parser ;
using NzbDrone.Core.Tv ;
@ -17,7 +18,6 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
{
private EpisodeFile _fakeEpisodeFile ;
private string [ ] _subFolders = new [ ] { "c:\\root\\foldername" } ;
private string [ ] _videoFiles = new [ ] { "c:\\root\\foldername\\video.ext" } ;
@ -32,6 +32,9 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
Mocker . GetMock < IDiskProvider > ( ) . Setup ( c = > c . GetDirectories ( It . IsAny < string > ( ) ) )
. Returns ( _subFolders ) ;
Mocker . GetMock < IConfigService > ( ) . SetupGet ( c = > c . DownloadedEpisodesFolder )
. Returns ( "c:\\drop\\" ) ;
}
private void WithOldWrite ( )
@ -55,7 +58,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
[Test]
public void should_import_file ( )
{
Subject . ProcessD r opFolder( "c:\\drop\\" ) ;
Subject . ProcessD ownloadedE piosdes Folder( ) ;
VerifyImport ( ) ;
}
@ -65,46 +68,29 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
{
WithRecentFolderWrite ( ) ;
Subject . ProcessD r opFolder( "c:\\drop\\" ) ;
Subject . ProcessD ownloadedE piosdes Folder( ) ;
VerifyNoImport ( ) ;
}
[Test]
public void should_search_for_series_using_folder_name ( )
{
WithOldWrite ( ) ;
Subject . ProcessD r opFolder( "c:\\drop\\" ) ;
Subject . ProcessD ownloadedE piosdes Folder( ) ;
Mocker . GetMock < IParsingService > ( ) . Verify ( c = > c . GetSeries ( "foldername" ) , Times . Once ( ) ) ;
}
[Test]
public void should_search_for_series_using_file_name ( )
{
/ * WithOldWrite ( ) ;
WithValidSeries ( ) ;
WithImportableFiles ( ) ;
var droppedFolder = new DirectoryInfo ( @"C:\Test\Unsorted TV\The Office - S01E01 - Episode Title" ) ;
Subject . ProcessDownload ( droppedFolder ) ;
Mocker . GetMock < DiskScanProvider > ( )
. Verify ( c = > c . Scan ( _fakeSeries , It . IsAny < string > ( ) ) ) ; * /
}
[Test]
public void all_imported_files_should_be_moved ( )
{
Mocker . GetMock < IDiskScanService > ( ) . Setup ( c = > c . ImportFile ( It . IsAny < Series > ( ) , It . IsAny < string > ( ) ) )
. Returns ( _fakeEpisodeFile ) ;
Subject . ProcessD r opFolder( "c:\\drop\\" ) ;
Subject . ProcessDownloadedEpiosdesFolder ( ) ;
Mocker . GetMock < IMoveEpisodeFiles > ( ) . Verify ( c = > c . MoveEpisodeFile ( _fakeEpisodeFile , true ) , Times . Once ( ) ) ;
}
@ -115,12 +101,11 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
Mocker . GetMock < IDiskScanService > ( ) . Setup ( c = > c . ImportFile ( It . IsAny < Series > ( ) , It . IsAny < string > ( ) ) )
. Returns < EpisodeFile > ( null ) ;
Subject . ProcessD r opFolder( "c:\\drop\\" ) ;
Subject . ProcessD ownloadedE piosdes Folder( ) ;
Mocker . GetMock < IMoveEpisodeFiles > ( ) . Verify ( c = > c . MoveEpisodeFile ( It . IsAny < EpisodeFile > ( ) , It . IsAny < bool > ( ) ) , Times . Never ( ) ) ;
}
[Test]
public void should_skip_if_folder_is_in_use_by_another_process ( )
{
@ -128,19 +113,16 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
Mocker . GetMock < IDiskProvider > ( ) . Setup ( c = > c . IsFileLocked ( It . IsAny < FileInfo > ( ) ) )
. Returns ( true ) ;
Subject . ProcessD r opFolder( "c:\\drop\\" ) ;
Subject . ProcessD ownloadedE piosdes Folder( ) ;
VerifyNoImport ( ) ;
}
private void VerifyNoImport ( )
{
Mocker . GetMock < IDiskScanService > ( ) . Verify ( c = > c . ImportFile ( It . IsAny < Series > ( ) , It . IsAny < string > ( ) ) ,
Times . Never ( ) ) ;
}
private void VerifyImport ( )
{
Mocker . GetMock < IDiskScanService > ( ) . Verify ( c = > c . ImportFile ( It . IsAny < Series > ( ) , It . IsAny < string > ( ) ) ,