2013-07-06 21:47:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2013-07-19 05:18:11 +00:00
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
2013-07-06 21:47:49 +00:00
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2014-06-08 08:22:55 +00:00
|
|
|
|
using NzbDrone.Core.Profiles;
|
2013-11-12 00:49:43 +00:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-07-06 21:47:49 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
using NzbDrone.Test.Common;
|
2014-01-18 11:44:36 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
2013-09-10 17:54:59 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
2013-07-06 21:47:49 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class ImportDecisionMakerFixture : CoreTest<ImportDecisionMaker>
|
|
|
|
|
{
|
2013-09-10 17:54:59 +00:00
|
|
|
|
private List<string> _videoFiles;
|
2013-07-06 21:47:49 +00:00
|
|
|
|
private LocalEpisode _localEpisode;
|
|
|
|
|
private Series _series;
|
2013-11-12 00:49:43 +00:00
|
|
|
|
private QualityModel _quality;
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
private Mock<IImportDecisionEngineSpecification> _pass1;
|
|
|
|
|
private Mock<IImportDecisionEngineSpecification> _pass2;
|
|
|
|
|
private Mock<IImportDecisionEngineSpecification> _pass3;
|
|
|
|
|
|
|
|
|
|
private Mock<IImportDecisionEngineSpecification> _fail1;
|
|
|
|
|
private Mock<IImportDecisionEngineSpecification> _fail2;
|
|
|
|
|
private Mock<IImportDecisionEngineSpecification> _fail3;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_pass1 = new Mock<IImportDecisionEngineSpecification>();
|
|
|
|
|
_pass2 = new Mock<IImportDecisionEngineSpecification>();
|
|
|
|
|
_pass3 = new Mock<IImportDecisionEngineSpecification>();
|
|
|
|
|
|
|
|
|
|
_fail1 = new Mock<IImportDecisionEngineSpecification>();
|
|
|
|
|
_fail2 = new Mock<IImportDecisionEngineSpecification>();
|
|
|
|
|
_fail3 = new Mock<IImportDecisionEngineSpecification>();
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Accept());
|
|
|
|
|
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Accept());
|
|
|
|
|
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Accept());
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Reject("_fail1"));
|
|
|
|
|
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Reject("_fail2"));
|
|
|
|
|
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Reject("_fail3"));
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
2014-01-18 11:44:36 +00:00
|
|
|
|
_series = Builder<Series>.CreateNew()
|
2014-06-08 08:22:55 +00:00
|
|
|
|
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
2014-01-18 11:44:36 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2013-11-12 00:49:43 +00:00
|
|
|
|
_quality = new QualityModel(Quality.DVD);
|
2015-01-27 05:57:07 +00:00
|
|
|
|
|
2013-11-12 00:49:43 +00:00
|
|
|
|
_localEpisode = new LocalEpisode
|
|
|
|
|
{
|
|
|
|
|
Series = _series,
|
|
|
|
|
Quality = _quality,
|
2015-05-11 22:49:41 +00:00
|
|
|
|
Episodes = new List<Episode> { new Episode() },
|
2013-11-12 00:49:43 +00:00
|
|
|
|
Path = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi"
|
|
|
|
|
};
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
2013-07-23 05:50:32 +00:00
|
|
|
|
Mocker.GetMock<IParsingService>()
|
2015-10-03 17:45:26 +00:00
|
|
|
|
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
2013-07-06 21:47:49 +00:00
|
|
|
|
.Returns(_localEpisode);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
GivenVideoFiles(new List<string> { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic() });
|
2013-07-06 21:47:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GivenSpecifications(params Mock<IImportDecisionEngineSpecification>[] mocks)
|
|
|
|
|
{
|
2015-01-27 05:57:07 +00:00
|
|
|
|
Mocker.SetConstant(mocks.Select(c => c.Object));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GivenVideoFiles(IEnumerable<string> videoFiles)
|
|
|
|
|
{
|
|
|
|
|
_videoFiles = videoFiles.ToList();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IMediaFileService>()
|
|
|
|
|
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
|
|
|
|
.Returns(_videoFiles);
|
2013-07-06 21:47:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_call_all_specifications()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
Subject.GetImportDecisions(_videoFiles, new Series(), null, false);
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
_fail1.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
|
|
|
|
_fail2.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
|
|
|
|
_fail3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
|
|
|
|
_pass1.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
|
|
|
|
_pass2.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
|
|
|
|
_pass3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_rejected_if_single_specs_fail()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_fail1);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
result.Single().Approved.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_rejected_if_one_of_specs_fail()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _fail1, _pass2, _pass3);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
result.Single().Approved.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_pass_if_all_specs_pass()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
result.Single().Approved.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_have_same_number_of_rejections_as_specs_that_failed()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
2013-07-06 21:47:49 +00:00
|
|
|
|
result.Single().Rejections.Should().HaveCount(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2014-09-04 00:57:27 +00:00
|
|
|
|
public void should_not_blowup_the_process_due_to_failed_parse()
|
2013-07-06 21:47:49 +00:00
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
|
2014-09-04 00:57:27 +00:00
|
|
|
|
Mocker.GetMock<IParsingService>()
|
2015-10-03 17:45:26 +00:00
|
|
|
|
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
2014-09-04 00:57:27 +00:00
|
|
|
|
.Throws<TestException>();
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
|
_videoFiles = new List<string>
|
2013-07-06 21:47:49 +00:00
|
|
|
|
{
|
|
|
|
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
|
|
|
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
|
|
|
|
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
|
|
|
|
};
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
GivenVideoFiles(_videoFiles);
|
2013-07-19 05:25:42 +00:00
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
Subject.GetImportDecisions(_videoFiles, _series);
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
2015-10-03 17:45:26 +00:00
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
|
2013-07-06 21:47:49 +00:00
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedErrors(3);
|
|
|
|
|
}
|
2013-11-12 00:49:43 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_use_file_quality_if_folder_quality_is_null()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
|
|
|
|
var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single());
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, _series);
|
2013-11-12 00:49:43 +00:00
|
|
|
|
|
|
|
|
|
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_use_file_quality_if_folder_quality_is_lower_than_file_quality()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
|
|
|
|
var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single());
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo{Quality = new QualityModel(Quality.SDTV)}, true);
|
2013-11-12 00:49:43 +00:00
|
|
|
|
|
|
|
|
|
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_use_folder_quality_when_it_is_greater_than_file_quality()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
|
|
|
|
var expectedQuality = new QualityModel(Quality.Bluray1080p);
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true);
|
2013-11-12 00:49:43 +00:00
|
|
|
|
|
|
|
|
|
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
|
|
|
|
}
|
2014-09-04 00:57:27 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_throw_if_episodes_are_not_found()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
2015-10-03 17:45:26 +00:00
|
|
|
|
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
2015-05-11 22:49:41 +00:00
|
|
|
|
.Returns(new LocalEpisode() { Path = "test" });
|
2014-09-04 00:57:27 +00:00
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
|
_videoFiles = new List<string>
|
2014-09-04 00:57:27 +00:00
|
|
|
|
{
|
|
|
|
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
|
|
|
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
|
|
|
|
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
|
|
|
|
};
|
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
GivenVideoFiles(_videoFiles);
|
|
|
|
|
|
2015-05-11 22:49:41 +00:00
|
|
|
|
var decisions = Subject.GetImportDecisions(_videoFiles, _series);
|
2015-01-27 05:57:07 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
2015-10-03 17:45:26 +00:00
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
|
2015-05-11 22:49:41 +00:00
|
|
|
|
|
|
|
|
|
decisions.Should().HaveCount(3);
|
|
|
|
|
decisions.First().Rejections.Should().NotBeEmpty();
|
2015-01-27 05:57:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_use_folder_for_full_season()
|
|
|
|
|
{
|
|
|
|
|
var videoFiles = new[]
|
|
|
|
|
{
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01\S01E01.mkv".AsOsAgnostic(),
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01\S01E02.mkv".AsOsAgnostic(),
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01\S01E03.mkv".AsOsAgnostic()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
GivenVideoFiles(videoFiles);
|
|
|
|
|
|
|
|
|
|
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01");
|
2014-09-04 00:57:27 +00:00
|
|
|
|
|
2015-01-27 05:57:07 +00:00
|
|
|
|
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Exactly(3));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(p => p != null), true), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_use_folder_when_it_contains_more_than_one_valid_video_file()
|
|
|
|
|
{
|
|
|
|
|
var videoFiles = new[]
|
|
|
|
|
{
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic(),
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01E01\1x01.mkv".AsOsAgnostic()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
GivenVideoFiles(videoFiles);
|
|
|
|
|
|
|
|
|
|
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
|
|
|
|
|
|
|
|
|
|
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Exactly(2));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(p => p != null), true), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_use_folder_when_only_one_video_file()
|
|
|
|
|
{
|
|
|
|
|
var videoFiles = new[]
|
|
|
|
|
{
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
GivenVideoFiles(videoFiles);
|
|
|
|
|
|
|
|
|
|
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
|
|
|
|
|
|
|
|
|
|
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), true), Times.Exactly(1));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_use_folder_when_only_one_video_file_and_a_sample()
|
|
|
|
|
{
|
|
|
|
|
var videoFiles = new[]
|
|
|
|
|
{
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic(),
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.sample.mkv".AsOsAgnostic()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
GivenVideoFiles(videoFiles.ToList());
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDetectSample>()
|
|
|
|
|
.Setup(s => s.IsSample(_series, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
|
|
|
|
|
|
|
|
|
|
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), true), Times.Exactly(2));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_use_folder_name_if_file_name_is_scene_name()
|
|
|
|
|
{
|
|
|
|
|
var videoFiles = new[]
|
|
|
|
|
{
|
|
|
|
|
@"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-LOL\Series.Title.S01E01.720p.HDTV-LOL.mkv".AsOsAgnostic()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GivenSpecifications(_pass1);
|
|
|
|
|
GivenVideoFiles(videoFiles);
|
|
|
|
|
|
|
|
|
|
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.720p.HDTV-LOL");
|
|
|
|
|
|
|
|
|
|
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Exactly(1));
|
2014-09-04 00:57:27 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
2015-01-27 05:57:07 +00:00
|
|
|
|
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(p => p != null), true), Times.Never());
|
2014-09-04 00:57:27 +00:00
|
|
|
|
}
|
2015-05-25 06:18:57 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_use_folder_quality_when_it_is_unknown()
|
|
|
|
|
{
|
|
|
|
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
|
|
|
|
|
|
|
|
|
_series.Profile = new Profile
|
|
|
|
|
{
|
|
|
|
|
Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.Unknown)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var folderQuality = new QualityModel(Quality.Unknown);
|
|
|
|
|
|
|
|
|
|
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = folderQuality}, true);
|
|
|
|
|
|
|
|
|
|
result.Single().LocalEpisode.Quality.Should().Be(_quality);
|
|
|
|
|
}
|
2013-07-06 21:47:49 +00:00
|
|
|
|
}
|
2015-01-27 05:57:07 +00:00
|
|
|
|
}
|