|
|
|
@ -14,7 +14,7 @@ using NzbDrone.Core.Tv;
|
|
|
|
|
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class SampleServiceFixture : CoreTest<DetectSample>
|
|
|
|
|
public class DetectSampleFixture : 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;
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -66,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|
|
|
|
{
|
|
|
|
|
_localEpisode.Path = @"C:\Test\some.show.s01e01.flv";
|
|
|
|
|
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
ShouldBeTrue();
|
|
|
|
|
ShouldBeSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -109,7 +101,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|
|
|
|
{
|
|
|
|
|
GivenRuntime(600);
|
|
|
|
|
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -118,7 +110,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|
|
|
|
_series.Runtime = 6;
|
|
|
|
|
GivenRuntime(299);
|
|
|
|
|
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -127,7 +119,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|
|
|
|
_series.Runtime = 2;
|
|
|
|
|
GivenRuntime(60);
|
|
|
|
|
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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;
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -176,25 +158,21 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|
|
|
|
_series.SeriesType = SeriesTypes.Anime;
|
|
|
|
|
_localEpisode.Episodes[0].SeasonNumber = 0;
|
|
|
|
|
|
|
|
|
|
ShouldBeFalse();
|
|
|
|
|
ShouldBeNotSample();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShouldBeTrue()
|
|
|
|
|
private void ShouldBeSample()
|
|
|
|
|
{
|
|
|
|
|
Subject.IsSample(_localEpisode.Series,
|
|
|
|
|
_localEpisode.Quality,
|
|
|
|
|
_localEpisode.Path,
|
|
|
|
|
_localEpisode.Size,
|
|
|
|
|
_localEpisode.IsSpecial).Should().BeTrue();
|
|
|
|
|
_localEpisode.Path,
|
|
|
|
|
_localEpisode.IsSpecial).Should().Be(DetectSampleResult.Sample);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShouldBeFalse()
|
|
|
|
|
private void ShouldBeNotSample()
|
|
|
|
|
{
|
|
|
|
|
Subject.IsSample(_localEpisode.Series,
|
|
|
|
|
_localEpisode.Quality,
|
|
|
|
|
_localEpisode.Path,
|
|
|
|
|
_localEpisode.Size,
|
|
|
|
|
_localEpisode.IsSpecial).Should().BeFalse();
|
|
|
|
|
_localEpisode.IsSpecial).Should().Be(DetectSampleResult.NotSample);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|