@ -14,7 +14,7 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{
[TestFixture]
public class SampleServic eFixture : CoreTest < DetectSample >
public class Detect SampleFixture : CoreTest < DetectSample >
{
private Series _series ;
private LocalEpisode _localEpisode ;
@ -42,11 +42,6 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
} ;
}
private void GivenFileSize ( long size )
{
_localEpisode . Size = size ;
}
private void GivenRuntime ( int seconds )
{
Mocker . GetMock < IVideoFileInfoReader > ( )
@ -58,7 +53,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
public void should_return_false_if_season_zero ( )
{
_localEpisode . Episodes [ 0 ] . SeasonNumber = 0 ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
}
[Test]
@ -66,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{
_localEpisode . Path = @"C:\Test\some.show.s01e01.flv" ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( c = > c . GetRunTime ( It . IsAny < string > ( ) ) , Times . Never ( ) ) ;
}
@ -76,7 +71,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{
_localEpisode . Path = @"C:\Test\some.show.s01e01.strm" ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( c = > c . GetRunTime ( It . IsAny < string > ( ) ) , Times . Never ( ) ) ;
}
@ -85,12 +80,9 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
public void should_use_runtime ( )
{
GivenRuntime ( 120 ) ;
GivenFileSize ( 1000. Megabytes ( ) ) ;
Subject . IsSample ( _localEpisode . Series ,
_localEpisode . Quality ,
_localEpisode . Path ,
_localEpisode . Size ,
_localEpisode . IsSpecial ) ;
Mocker . GetMock < IVideoFileInfoReader > ( ) . Verify ( v = > v . GetRunTime ( It . IsAny < string > ( ) ) , Times . Once ( ) ) ;
@ -101,7 +93,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{
GivenRuntime ( 60 ) ;
ShouldBe Tru e( ) ;
ShouldBe Sampl e( ) ;
}
[Test]
@ -109,7 +101,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{
GivenRuntime ( 600 ) ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
}
[Test]
@ -118,7 +110,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_series . Runtime = 6 ;
GivenRuntime ( 299 ) ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
}
[Test]
@ -127,7 +119,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_series . Runtime = 2 ;
GivenRuntime ( 60 ) ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
}
[Test]
@ -136,29 +128,19 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_series . Runtime = 2 ;
GivenRuntime ( 10 ) ;
ShouldBeTrue ( ) ;
}
[Test]
public void should_fall_back_to_file_size_if_mediainfo_dll_not_found_acceptable_size ( )
{
Mocker . GetMock < IVideoFileInfoReader > ( )
. Setup ( s = > s . GetRunTime ( It . IsAny < string > ( ) ) )
. Throws < DllNotFoundException > ( ) ;
GivenFileSize ( 1000. Megabytes ( ) ) ;
ShouldBeFalse ( ) ;
ShouldBeSample ( ) ;
}
[Test]
public void should_ fall_back_to_file_size_if_mediainfo_dll_not_found_undersize ( )
public void should_return_indeterminate_if_mediainfo_result_is_null ( )
{
Mocker . GetMock < IVideoFileInfoReader > ( )
. Setup ( s = > s . GetRunTime ( It . IsAny < string > ( ) ) )
. Throws < DllNotFoundException > ( ) ;
GivenFileSize ( 1. Megabytes ( ) ) ;
ShouldBeTrue ( ) ;
Subject . IsSample ( _localEpisode . Series ,
_localEpisode . Path ,
_localEpisode . IsSpecial ) . Should ( ) . Be ( DetectSampleResult . Indeterminate ) ;
}
[Test]
@ -167,7 +149,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
GivenRuntime ( 600 ) ;
_series . SeriesType = SeriesTypes . Daily ;
_localEpisode . Episodes [ 0 ] . SeasonNumber = 0 ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
}
[Test]
@ -176,25 +158,21 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_series . SeriesType = SeriesTypes . Anime ;
_localEpisode . Episodes [ 0 ] . SeasonNumber = 0 ;
ShouldBe Fals e( ) ;
ShouldBe NotSampl e( ) ;
}
private void ShouldBe Tru e( )
private void ShouldBe Sampl e( )
{
Subject . IsSample ( _localEpisode . Series ,
_localEpisode . Quality ,
_localEpisode . Path ,
_localEpisode . Size ,
_localEpisode . IsSpecial ) . Should ( ) . BeTrue ( ) ;
_localEpisode . Path ,
_localEpisode . IsSpecial ) . Should ( ) . Be ( DetectSampleResult . Sample ) ;
}
private void ShouldBe Fals e( )
private void ShouldBe NotSampl e( )
{
Subject . IsSample ( _localEpisode . Series ,
_localEpisode . Quality ,
_localEpisode . Path ,
_localEpisode . Size ,
_localEpisode . IsSpecial ) . Should ( ) . BeFalse ( ) ;
_localEpisode . IsSpecial ) . Should ( ) . Be ( DetectSampleResult . NotSample ) ;
}
}
}