mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-27 23:06:29 -04:00
@@ -13,11 +13,13 @@ using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
@@ -25,6 +27,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
public class DelaySpecificationFixture : CoreTest<DelaySpecification>
|
||||
{
|
||||
private Profile _profile;
|
||||
private LanguageProfile _langProfile;
|
||||
private DelayProfile _delayProfile;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
@@ -34,12 +37,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_profile = Builder<Profile>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_langProfile = Builder<LanguageProfile>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_delayProfile = Builder<DelayProfile>.CreateNew()
|
||||
.With(d => d.PreferredProtocol = DownloadProtocol.Usenet)
|
||||
.Build();
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Profile = _profile)
|
||||
.With(s => s.LanguageProfile = _langProfile)
|
||||
.Build();
|
||||
|
||||
_remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
@@ -53,6 +60,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
|
||||
_profile.Cutoff = Quality.WEBDL720p;
|
||||
|
||||
_langProfile.Cutoff = Language.Spanish;
|
||||
_langProfile.Languages = Languages.LanguageFixture.GetDefaultLanguages();
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
_remoteEpisode.Release = new ReleaseInfo();
|
||||
_remoteEpisode.Release.DownloadProtocol = DownloadProtocol.Usenet;
|
||||
@@ -69,20 +79,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
.Returns(new List<RemoteEpisode>());
|
||||
}
|
||||
|
||||
private void GivenExistingFile(QualityModel quality)
|
||||
private void GivenExistingFile(QualityModel quality, Language language)
|
||||
{
|
||||
_remoteEpisode.Episodes.First().EpisodeFileId = 1;
|
||||
|
||||
_remoteEpisode.Episodes.First().EpisodeFile = new LazyLoaded<EpisodeFile>(new EpisodeFile
|
||||
{
|
||||
Quality = quality
|
||||
Quality = quality,
|
||||
Language = language
|
||||
});
|
||||
}
|
||||
|
||||
private void GivenUpgradeForExistingFile()
|
||||
{
|
||||
Mocker.GetMock<IQualityUpgradableSpecification>()
|
||||
.Setup(s => s.IsUpgradable(It.IsAny<Profile>(), It.IsAny<QualityModel>(), It.IsAny<QualityModel>()))
|
||||
Mocker.GetMock<IUpgradableSpecification>()
|
||||
.Setup(s => s.IsUpgradable(It.IsAny<Profile>(), It.IsAny<LanguageProfile>(), It.IsAny<QualityModel>(), It.IsAny<Language>(), It.IsAny<QualityModel>(), It.IsAny<Language>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
@@ -112,9 +123,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_quality_is_last_allowed_in_profile()
|
||||
public void should_be_true_when_quality_and_language_is_last_allowed_in_profile()
|
||||
{
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray720p);
|
||||
_remoteEpisode.ParsedEpisodeInfo.Language = Language.French;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
@@ -147,10 +159,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 2));
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.HDTV720p));
|
||||
GivenExistingFile(new QualityModel(Quality.HDTV720p), Language.English);
|
||||
GivenUpgradeForExistingFile();
|
||||
|
||||
Mocker.GetMock<IQualityUpgradableSpecification>()
|
||||
Mocker.GetMock<IUpgradableSpecification>()
|
||||
.Setup(s => s.IsRevisionUpgrade(It.IsAny<QualityModel>(), It.IsAny<QualityModel>()))
|
||||
.Returns(true);
|
||||
|
||||
@@ -165,10 +177,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p, new Revision(real: 1));
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.HDTV720p));
|
||||
GivenExistingFile(new QualityModel(Quality.HDTV720p), Language.English);
|
||||
GivenUpgradeForExistingFile();
|
||||
|
||||
Mocker.GetMock<IQualityUpgradableSpecification>()
|
||||
Mocker.GetMock<IUpgradableSpecification>()
|
||||
.Setup(s => s.IsRevisionUpgrade(It.IsAny<QualityModel>(), It.IsAny<QualityModel>()))
|
||||
.Returns(true);
|
||||
|
||||
@@ -183,7 +195,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 2));
|
||||
_remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.SDTV));
|
||||
GivenExistingFile(new QualityModel(Quality.SDTV), Language.English);
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user