@ -7,6 +7,7 @@ using NUnit.Framework;
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications ;
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications ;
using NzbDrone.Core.MediaFiles.MediaInfo ;
using NzbDrone.Core.MediaFiles.MediaInfo ;
using NzbDrone.Core.Parser.Model ;
using NzbDrone.Core.Parser.Model ;
using NzbDrone.Core.Qualities ;
using NzbDrone.Core.Test.Framework ;
using NzbDrone.Core.Test.Framework ;
using NzbDrone.Core.Tv ;
using NzbDrone.Core.Tv ;
using NzbDrone.Test.Common ;
using NzbDrone.Test.Common ;
@ -36,112 +37,113 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
{
{
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi" ,
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi" ,
Episodes = episodes ,
Episodes = episodes ,
Series = _series
Series = _series ,
Quality = new QualityModel ( Quality . HDTV720p )
} ;
} ;
}
}
private void WithDailySeries ( )
private void GivenFileSize ( long size )
{
_series . SeriesType = SeriesTypes . Daily ;
}
private void WithSeasonZero ( )
{
_localEpisode . Episodes [ 0 ] . SeasonNumber = 0 ;
}
private void WithFileSize ( long size )
{
{
_localEpisode . Size = size ;
_localEpisode . Size = size ;
}
}
private void WithLength( int minute s)
private void GivenRuntime ( int seconds )
{
{
Mocker . GetMock < IVideoFileInfoReader > ( )
Mocker . GetMock < IVideoFileInfoReader > ( )
. Setup ( s = > s . GetRunTime ( It . IsAny < String > ( ) ) )
. Setup ( s = > s . GetRunTime ( It . IsAny < String > ( ) ) )
. Returns ( new TimeSpan ( 0 , 0 , minutes, 0 ) ) ;
. Returns ( new TimeSpan ( 0 , 0 , seconds ) ) ;
}
}
[Test]
[Test]
public void should_return_true_if_series_is_daily ( )
public void should_return_true_if_series_is_daily ( )
{
{
WithDailySeries ( ) ;
_series . SeriesType = SeriesTypes . Daily ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
}
}
[Test]
[Test]
public void should_return_true_if_season_zero ( )
public void should_return_true_if_season_zero ( )
{
{
WithSeasonZero ( ) ;
_localEpisode . Episodes [ 0 ] . SeasonNumber = 0 ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
}
[Test]
public void should_return_true_for_existing_file ( )
{
_localEpisode . ExistingFile = true ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
}
}
[Test]
[Test]
public void should_return_ false_if_undersize_and_under_length ( )
public void should_return_ true_for_flv ( )
{
{
WithFileSize ( 10. Megabytes ( ) ) ;
_localEpisode . Path = @"C:\Test\some.show.s01e01.flv" ;
WithLength ( 1 ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeFalse ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( c = > c . GetRunTime ( It . IsAny < string > ( ) ) , Times . Never ( ) ) ;
}
}
[Test]
[Test]
public void should_ return_true_if_undersize ( )
public void should_ not_run_runtime_check_on_linux ( )
{
{
WithFileSize( 10. Megabytes ( ) ) ;
LinuxOnly( ) ;
WithLength( 10 ) ;
GivenFileSize( 1000. Megabytes ( ) ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( v = > v . GetRunTime ( It . IsAny < String > ( ) ) , Times . Never ( ) ) ;
}
}
[Test]
[Test]
public void should_r eturn_true_if_under_length ( )
public void should_r un_runtime_check_on_windows ( )
{
{
WithFileSize( 100. Megabytes ( ) ) ;
GivenRuntime( 120 ) ;
WithLength( 1 ) ;
GivenFileSize( 1000. Megabytes ( ) ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( v = > v . GetRunTime ( It . IsAny < String > ( ) ) , Times . Once ( ) ) ;
}
}
[Test]
[Test]
public void should_return_ true_if_over_size_and_length ( )
public void should_return_ false_if_runtime_is_less_than_minimum ( )
{
{
WithFileSize ( 100. Megabytes ( ) ) ;
GivenRuntime ( 60 ) ;
WithLength ( 10 ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . Be Tru e( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . Be Fals e( ) ;
}
}
[Test]
[Test]
public void should_ not_check_lenght_if_file_is_large_enough ( )
public void should_ return_true_if_runtime_greater_than_than_minimum ( )
{
{
WithFileSize( 100. Megabytes ( ) ) ;
GivenRuntime( 120 ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( c = > c . GetRunTime ( It . IsAny < string > ( ) ) , Times . Never ( ) ) ;
}
}
[Test]
[Test]
public void should_ log_error_if_run_time_is_0_and_under_sample_size ( )
public void should_ return_false_if_file_size_is_under_minimum ( )
{
{
WithFileSize ( 40. Megabytes ( ) ) ;
LinuxOnly ( ) ;
WithLength ( 0 ) ;
GivenRuntime ( 120 ) ;
GivenFileSize ( 20. Megabytes ( ) ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeFalse ( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeFalse ( ) ;
ExceptionVerification . ExpectedErrors ( 1 ) ;
}
}
[Test]
[Test]
public void should_ skip_check_for_flv_file ( )
public void should_ return_false_if_file_size_is_under_minimum_for_larger_limits ( )
{
{
_localEpisode. Path = @"C:\Test\some.show.s01e01.flv" ;
LinuxOnly( ) ;
Subject . IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeTrue ( ) ;
GivenRuntime ( 120 ) ;
GivenFileSize ( 120. Megabytes ( ) ) ;
_localEpisode . Quality = new QualityModel ( Quality . Bluray1080p ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( c = > c . GetRunTime ( It . IsAny < string > ( ) ) , Times . Never ( ) ) ;
Subject. IsSatisfiedBy ( _localEpisode ) . Should ( ) . BeFalse ( ) ;
}
}
}
}
}
}