2021-08-04 04:00:28 +00:00
|
|
|
using System.Linq;
|
2014-10-05 06:04:19 +00:00
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
2022-12-12 02:01:51 +00:00
|
|
|
using NzbDrone.Core.Configuration;
|
2014-10-05 06:04:19 +00:00
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2021-08-03 04:43:28 +00:00
|
|
|
using NzbDrone.Core.Tv;
|
2014-10-05 06:04:19 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class AnimeVersionUpgradeSpecificationFixture : CoreTest<AnimeVersionUpgradeSpecification>
|
|
|
|
{
|
|
|
|
private AnimeVersionUpgradeSpecification _subject;
|
|
|
|
private RemoteEpisode _remoteEpisode;
|
|
|
|
private EpisodeFile _episodeFile;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2022-12-12 02:01:51 +00:00
|
|
|
Mocker.GetMock<IConfigService>()
|
|
|
|
.Setup(s => s.DownloadPropersAndRepacks)
|
|
|
|
.Returns(ProperDownloadTypes.PreferAndUpgrade);
|
|
|
|
|
2015-07-12 16:44:33 +00:00
|
|
|
Mocker.Resolve<UpgradableSpecification>();
|
2014-10-05 06:04:19 +00:00
|
|
|
_subject = Mocker.Resolve<AnimeVersionUpgradeSpecification>();
|
|
|
|
|
|
|
|
_episodeFile = new EpisodeFile
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.HDTV720p, new Revision()),
|
|
|
|
ReleaseGroup = "DRONE2"
|
|
|
|
};
|
|
|
|
|
|
|
|
_remoteEpisode = new RemoteEpisode();
|
|
|
|
_remoteEpisode.Series = new Series { SeriesType = SeriesTypes.Anime };
|
|
|
|
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.HDTV720p, new Revision(2)),
|
|
|
|
ReleaseGroup = "DRONE"
|
|
|
|
};
|
|
|
|
|
|
|
|
_remoteEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
.All()
|
2021-08-04 04:00:28 +00:00
|
|
|
.With(e => e.EpisodeFile = _episodeFile)
|
2014-10-05 06:04:19 +00:00
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void GivenStandardSeries()
|
|
|
|
{
|
|
|
|
_remoteEpisode.Series.SeriesType = SeriesTypes.Standard;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void GivenNoVersionUpgrade()
|
|
|
|
{
|
|
|
|
_remoteEpisode.ParsedEpisodeInfo.Quality.Revision = new Revision();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_be_true_when_no_existing_file()
|
|
|
|
{
|
|
|
|
_remoteEpisode.Episodes.First().EpisodeFileId = 0;
|
|
|
|
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_be_true_if_series_is_not_anime()
|
|
|
|
{
|
|
|
|
GivenStandardSeries();
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_be_true_if_is_not_a_version_upgrade_for_existing_file()
|
|
|
|
{
|
|
|
|
GivenNoVersionUpgrade();
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_be_true_when_release_group_matches()
|
|
|
|
{
|
|
|
|
_episodeFile.ReleaseGroup = _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup;
|
|
|
|
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_be_false_when_existing_file_doesnt_have_a_release_group()
|
|
|
|
{
|
2015-10-03 17:45:26 +00:00
|
|
|
_episodeFile.ReleaseGroup = string.Empty;
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_should_be_false_when_release_doesnt_have_a_release_group()
|
|
|
|
{
|
2015-10-03 17:45:26 +00:00
|
|
|
_remoteEpisode.ParsedEpisodeInfo.ReleaseGroup = string.Empty;
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_be_false_when_release_group_does_not_match()
|
|
|
|
{
|
2014-10-27 05:51:50 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
2022-12-12 02:01:51 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_return_true_when_repacks_are_not_preferred()
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IConfigService>()
|
|
|
|
.Setup(s => s.DownloadPropersAndRepacks)
|
|
|
|
.Returns(ProperDownloadTypes.DoNotPrefer);
|
|
|
|
|
2022-12-12 03:42:44 +00:00
|
|
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
2022-12-12 02:01:51 +00:00
|
|
|
}
|
2014-10-05 06:04:19 +00:00
|
|
|
}
|
2021-08-03 04:43:28 +00:00
|
|
|
}
|