1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-27 23:06:29 -04:00

New: Use release quality source if not in downloaded file and resolution matches

This commit is contained in:
Mark McDowall
2020-04-26 12:53:29 -07:00
committed by Mark McDowall
parent 0ff08dbe8d
commit 430af0401c
34 changed files with 480 additions and 278 deletions
@@ -44,7 +44,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(fileEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
@@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, true);
Subject.Aggregate(localEpisode, null, true);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(fileEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
@@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(fileEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
@@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(folderEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
@@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(fileEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
@@ -143,7 +143,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
.Setup(s => s.ParseSpecialEpisodeTitle(fileEpisodeInfo, It.IsAny<string>(), _series))
.Returns(specialEpisodeInfo);
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(specialEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
@@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
{
_localEpisode.FileEpisodeInfo = GetParsedEpisodeInfo(Language.English);
Subject.Aggregate(_localEpisode, false).Language.Should().Be(_localEpisode.FileEpisodeInfo.Language);
Subject.Aggregate(_localEpisode, null, false).Language.Should().Be(_localEpisode.FileEpisodeInfo.Language);
}
[Test]
@@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
_localEpisode.FolderEpisodeInfo = GetParsedEpisodeInfo(Language.English);
_localEpisode.FileEpisodeInfo = GetParsedEpisodeInfo(Language.English);
Subject.Aggregate(_localEpisode, false).Language.Should().Be(_localEpisode.FolderEpisodeInfo.Language);
Subject.Aggregate(_localEpisode, null, false).Language.Should().Be(_localEpisode.FolderEpisodeInfo.Language);
}
[Test]
@@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
_localEpisode.FolderEpisodeInfo = GetParsedEpisodeInfo(Language.English);
_localEpisode.FileEpisodeInfo = GetParsedEpisodeInfo(Language.English);
Subject.Aggregate(_localEpisode, false).Language.Should().Be(_localEpisode.DownloadClientEpisodeInfo.Language);
Subject.Aggregate(_localEpisode, null, false).Language.Should().Be(_localEpisode.DownloadClientEpisodeInfo.Language);
}
@@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
_localEpisode.FolderEpisodeInfo = GetParsedEpisodeInfo(Language.English);
_localEpisode.FileEpisodeInfo = GetParsedEpisodeInfo(Language.French);
Subject.Aggregate(_localEpisode, false).Language.Should().Be(_localEpisode.FileEpisodeInfo.Language);
Subject.Aggregate(_localEpisode, null, false).Language.Should().Be(_localEpisode.FileEpisodeInfo.Language);
}
}
}
@@ -3,6 +3,7 @@ using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators;
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augmenters.Quality;
using NzbDrone.Core.Parser.Model;
@@ -12,11 +13,12 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
{
[TestFixture]
public class AugmentQualityFixture : CoreTest<AggregateQuality>
public class AggregateQualityFixture : CoreTest<AggregateQuality>
{
private Mock<IAugmentQuality> _mediaInfoAugmenter;
private Mock<IAugmentQuality> _fileExtensionAugmenter;
private Mock<IAugmentQuality> _nameAugmenter;
private Mock<IAugmentQuality> _releaseNameAugmenter;
[SetUp]
public void Setup()
@@ -24,15 +26,24 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
_mediaInfoAugmenter = new Mock<IAugmentQuality>();
_fileExtensionAugmenter = new Mock<IAugmentQuality>();
_nameAugmenter = new Mock<IAugmentQuality>();
_releaseNameAugmenter = new Mock<IAugmentQuality>();
_mediaInfoAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>()))
_fileExtensionAugmenter.SetupGet(s => s.Order).Returns(1);
_nameAugmenter.SetupGet(s => s.Order).Returns(2);
_mediaInfoAugmenter.SetupGet(s => s.Order).Returns(4);
_releaseNameAugmenter.SetupGet(s => s.Order).Returns(5);
_mediaInfoAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(AugmentQualityResult.ResolutionOnly(1080, Confidence.MediaInfo));
_fileExtensionAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>()))
_fileExtensionAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(new AugmentQualityResult(QualitySource.Television, Confidence.Fallback, 720, Confidence.Fallback, new Revision()));
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>()))
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(new AugmentQualityResult(QualitySource.Television, Confidence.Default, 480, Confidence.Default, new Revision()));
_releaseNameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(AugmentQualityResult.SourceOnly(QualitySource.Web, Confidence.MediaInfo));
}
private void GivenAugmenters(params Mock<IAugmentQuality>[] mocks)
@@ -44,14 +55,15 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
public void should_return_HDTV720_from_extension_when_other_augments_are_null()
{
var nullMock = new Mock<IAugmentQuality>();
nullMock.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>()))
.Returns<LocalEpisode>(l => null);
nullMock.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns<LocalEpisode, DownloadClientItem>((l, d) => null);
GivenAugmenters(_fileExtensionAugmenter, nullMock);
var result = Subject.Aggregate(new LocalEpisode(), false);
var result = Subject.Aggregate(new LocalEpisode(), null, false);
result.Quality.QualityDetectionSource.Should().Be(QualityDetectionSource.Extension);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Extension);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Extension);
result.Quality.Quality.Should().Be(Quality.HDTV720p);
}
@@ -60,9 +72,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
{
GivenAugmenters(_fileExtensionAugmenter, _nameAugmenter);
var result = Subject.Aggregate(new LocalEpisode(), false);
var result = Subject.Aggregate(new LocalEpisode(), null, false);
result.Quality.QualityDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.Quality.Should().Be(Quality.SDTV);
}
@@ -71,9 +84,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
{
GivenAugmenters(_fileExtensionAugmenter, _mediaInfoAugmenter);
var result = Subject.Aggregate(new LocalEpisode(), false);
var result = Subject.Aggregate(new LocalEpisode(), null, false);
result.Quality.QualityDetectionSource.Should().Be(QualityDetectionSource.MediaInfo);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Extension);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.MediaInfo);
result.Quality.Quality.Should().Be(Quality.HDTV1080p);
}
@@ -82,10 +96,23 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
{
GivenAugmenters(_nameAugmenter, _mediaInfoAugmenter);
var result = Subject.Aggregate(new LocalEpisode(), false);
var result = Subject.Aggregate(new LocalEpisode(), null, false);
result.Quality.QualityDetectionSource.Should().Be(QualityDetectionSource.MediaInfo);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.MediaInfo);
result.Quality.Quality.Should().Be(Quality.HDTV1080p);
}
[Test]
public void should_return_WEBDL480p_when_file_name_has_HDTV480p_but_release_name_indicates_webdl_source()
{
GivenAugmenters(_nameAugmenter, _releaseNameAugmenter);
var result = Subject.Aggregate(new LocalEpisode(), new DownloadClientItem(), false);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.Quality.Should().Be(Quality.WEBDL480p);
}
}
}
@@ -1,8 +1,6 @@

using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators;
using NzbDrone.Core.Parser.Model;
@@ -36,7 +34,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
localEpisode.ReleaseGroup.Should().Be("Wizzy");
}
@@ -54,7 +52,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
localEpisode.ReleaseGroup.Should().Be("Wizzy");
}
@@ -74,7 +72,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
localEpisode.ReleaseGroup.Should().Be("Viva");
}
@@ -94,7 +92,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
localEpisode.ReleaseGroup.Should().Be("Drone");
}
@@ -114,7 +112,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Series = _series
};
Subject.Aggregate(localEpisode, false);
Subject.Aggregate(localEpisode, null, false);
localEpisode.ReleaseGroup.Should().Be("Wizzy");
}
@@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators.Au
.With(l => l.MediaInfo = null)
.Build();
Subject.AugmentQuality(localEpisode).Should().Be(null);
Subject.AugmentQuality(localEpisode, null).Should().Be(null);
}
[Test]
@@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators.Au
.With(l => l.MediaInfo = mediaInfo)
.Build();
Subject.AugmentQuality(localEpisode).Should().Be(null);
Subject.AugmentQuality(localEpisode, null).Should().Be(null);
}
[TestCase(4096, 2160)] // True 4K
@@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators.Au
.With(l => l.MediaInfo = mediaInfo)
.Build();
var result = Subject.AugmentQuality(localEpisode);
var result = Subject.AugmentQuality(localEpisode, null);
result.Should().NotBe(null);
result.Resolution.Should().Be(expectedResolution);
@@ -0,0 +1,79 @@
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.History;
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augmenters.Quality;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augmenters.Quality
{
[TestFixture]
public class AugmentQualityFromReleaseNameFixture : CoreTest<AugmentQualityFromReleaseName>
{
private LocalEpisode _localEpisode;
private DownloadClientItem _downloadClientItem;
private ParsedEpisodeInfo _hdtvParsedEpisodeInfo;
private ParsedEpisodeInfo _webdlParsedEpisodeInfo;
[SetUp]
public void Setup()
{
_hdtvParsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew()
.With(p => p.Quality =
new QualityModel(Core.Qualities.Quality.HDTV720p))
.Build();
_webdlParsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew()
.With(p => p.Quality =
new QualityModel(Core.Qualities.Quality.WEBDL720p))
.Build();
_localEpisode = Builder<LocalEpisode>.CreateNew()
.Build();
_downloadClientItem = Builder<DownloadClientItem>.CreateNew()
.Build();
}
[Test]
public void should_return_null_if_download_client_item_is_null()
{
Subject.AugmentQuality(_localEpisode, null).Should().BeNull();
}
[Test]
public void should_return_null_if_no_grabbed_history()
{
Mocker.GetMock<IDownloadHistoryService>()
.Setup(s => s.GetLatestGrab(It.IsAny<string>()))
.Returns((DownloadHistory)null);
Subject.AugmentQuality(_localEpisode, _downloadClientItem).Should().BeNull();
}
[TestCase("Series.Title.S01E01.1080p.WEB.x264", QualitySource.Web, Confidence.Tag, 1080, Confidence.Tag)]
[TestCase("Series.Title.S01E01.WEB.x264", QualitySource.Web, Confidence.Tag, 480, Confidence.Fallback)]
[TestCase("Series.Title.S01E01.720p.x264", QualitySource.Television, Confidence.Fallback, 720, Confidence.Tag)]
public void should_return_augmented_quality(string title, QualitySource source, Confidence sourceConfidence, int resolution, Confidence resolutionConfidence)
{
Mocker.GetMock<IDownloadHistoryService>()
.Setup(s => s.GetLatestGrab(It.IsAny<string>()))
.Returns(Builder<DownloadHistory>.CreateNew()
.With(h => h.SourceTitle = title)
.Build()
);
var result = Subject.AugmentQuality(_localEpisode, _downloadClientItem);
result.Should().NotBe(null);
result.Source.Should().Be(source);
result.SourceConfidence.Should().Be(sourceConfidence);
result.Resolution.Should().Be(resolution);
result.ResolutionConfidence.Should().Be(resolutionConfidence);
}
}
}
@@ -25,6 +25,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{
private List<string> _videoFiles;
private LocalEpisode _localEpisode;
private DownloadClientItem _downloadClientItem;
private Series _series;
private QualityModel _quality;
@@ -92,8 +93,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
private void GivenAugmentationSuccess()
{
Mocker.GetMock<IAggregationService>()
.Setup(s => s.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
.Callback<LocalEpisode, bool>((localEpisode, otherFiles) =>
.Setup(s => s.Augment(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()))
.Callback<LocalEpisode, DownloadClientItem, bool>((localEpisode, downloadClientItem, otherFiles) =>
{
localEpisode.Episodes = _localEpisode.Episodes;
});
@@ -163,7 +164,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
GivenSpecifications(_pass1);
Mocker.GetMock<IAggregationService>()
.Setup(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
.Setup(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()))
.Throws<TestException>();
_videoFiles = new List<string>
@@ -178,7 +179,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
Subject.GetImportDecisions(_videoFiles, _series);
Mocker.GetMock<IAggregationService>()
.Verify(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
.Verify(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
ExceptionVerification.ExpectedErrors(3);
}
@@ -199,7 +200,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
var decisions = Subject.GetImportDecisions(_videoFiles, _series);
Mocker.GetMock<IAggregationService>()
.Verify(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
.Verify(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
decisions.Should().HaveCount(3);
decisions.First().Rejections.Should().NotBeEmpty();
@@ -209,7 +210,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
public void should_return_a_decision_when_exception_is_caught()
{
Mocker.GetMock<IAggregationService>()
.Setup(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
.Setup(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()))
.Throws<TestException>();
_videoFiles = new List<string>
@@ -1,106 +0,0 @@
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Marr.Data;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles.Qualities;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
{
[TestFixture]
public class DifferentQualitySpecificationFixture : CoreTest<DifferentQualitySpecification>
{
private LocalEpisode _localEpisode;
private DownloadClientItem _downloadClientItem;
[SetUp]
public void Setup()
{
var qualityProfile = new QualityProfile
{
Cutoff = Quality.Bluray1080p.Id,
Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p)
};
var fakeSeries = Builder<Series>.CreateNew()
.With(c => c.QualityProfile = qualityProfile)
.Build();
_localEpisode = Builder<LocalEpisode>.CreateNew()
.With(l => l.Quality = new QualityModel(Quality.Bluray1080p))
.With(l => l.DownloadClientEpisodeInfo = new ParsedEpisodeInfo())
.With(l => l.Series = fakeSeries)
.Build();
_downloadClientItem = Builder<DownloadClientItem>.CreateNew()
.Build();
}
private void GivenGrabbedEpisodeHistory(QualityModel quality)
{
var history = Builder<EpisodeHistory>.CreateListOfSize(1)
.TheFirst(1)
.With(h => h.Quality = quality)
.With(h => h.EventType = EpisodeHistoryEventType.Grabbed)
.BuildList();
Mocker.GetMock<IHistoryService>()
.Setup(s => s.FindByDownloadId(It.IsAny<string>()))
.Returns(history);
}
[Test]
public void should_be_accepted_if_no_download_client_item()
{
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
[Test]
public void should_be_accepted_if_quality_does_not_match_for_full_season_pack()
{
GivenGrabbedEpisodeHistory(new QualityModel(Quality.SDTV));
_localEpisode.DownloadClientEpisodeInfo.FullSeason = true;
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
}
[Test]
public void should_be_accepted_if_no_grabbed_episode_history()
{
Mocker.GetMock<IHistoryService>()
.Setup(s => s.FindByDownloadId(It.IsAny<string>()))
.Returns(new List<EpisodeHistory>());
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
.TheFirst(1)
.With(e => e.EpisodeFileId = 0)
.BuildList();
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
}
[Test]
public void should_be_accepted_if_quality_matches()
{
GivenGrabbedEpisodeHistory(_localEpisode.Quality);
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
}
[Test]
public void should_be_rejected_if_quality_does_not_match()
{
GivenGrabbedEpisodeHistory(new QualityModel(Quality.SDTV));
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeFalse();
}
}
}