2014-12-03 01:18:17 +00:00
|
|
|
|
using System.Collections.Generic;
|
2022-07-19 20:08:53 +00:00
|
|
|
|
using System.Linq;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
|
|
|
using NzbDrone.Core.Indexers;
|
2020-01-03 12:49:24 +00:00
|
|
|
|
using NzbDrone.Core.Music;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
using NzbDrone.Core.Profiles.Delay;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class ProtocolSpecificationFixture : CoreTest<ProtocolSpecification>
|
|
|
|
|
{
|
2017-08-14 02:58:42 +00:00
|
|
|
|
private RemoteAlbum _remoteAlbum;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
private DelayProfile _delayProfile;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2017-08-14 02:58:42 +00:00
|
|
|
|
_remoteAlbum = new RemoteAlbum();
|
|
|
|
|
_remoteAlbum.Release = new ReleaseInfo();
|
|
|
|
|
_remoteAlbum.Artist = new Artist();
|
2020-01-03 12:49:24 +00:00
|
|
|
|
|
2014-12-03 01:18:17 +00:00
|
|
|
|
_delayProfile = new DelayProfile();
|
2022-07-19 20:08:53 +00:00
|
|
|
|
_delayProfile.Items.ForEach(x => x.Allowed = false);
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDelayProfileService>()
|
|
|
|
|
.Setup(s => s.BestForTags(It.IsAny<HashSet<int>>()))
|
|
|
|
|
.Returns(_delayProfile);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-19 20:08:53 +00:00
|
|
|
|
private void GivenProtocol(string downloadProtocol)
|
2014-12-03 01:18:17 +00:00
|
|
|
|
{
|
2017-08-14 02:58:42 +00:00
|
|
|
|
_remoteAlbum.Release.DownloadProtocol = downloadProtocol;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_true_if_usenet_and_usenet_is_enabled()
|
|
|
|
|
{
|
2022-07-19 20:08:53 +00:00
|
|
|
|
GivenProtocol(nameof(UsenetDownloadProtocol));
|
|
|
|
|
_delayProfile.Items.Single(x => x.Protocol == nameof(UsenetDownloadProtocol)).Allowed = true;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
2017-08-14 02:58:42 +00:00
|
|
|
|
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(true);
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_true_if_torrent_and_torrent_is_enabled()
|
|
|
|
|
{
|
2022-07-19 20:08:53 +00:00
|
|
|
|
GivenProtocol(nameof(TorrentDownloadProtocol));
|
|
|
|
|
_delayProfile.Items.Single(x => x.Protocol == nameof(TorrentDownloadProtocol)).Allowed = true;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
2017-08-14 02:58:42 +00:00
|
|
|
|
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(true);
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_false_if_usenet_and_usenet_is_disabled()
|
|
|
|
|
{
|
2022-07-19 20:08:53 +00:00
|
|
|
|
GivenProtocol(nameof(UsenetDownloadProtocol));
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
2017-08-14 02:58:42 +00:00
|
|
|
|
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false);
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_false_if_torrent_and_torrent_is_disabled()
|
|
|
|
|
{
|
2022-07-19 20:08:53 +00:00
|
|
|
|
GivenProtocol(nameof(TorrentDownloadProtocol));
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
2017-08-14 02:58:42 +00:00
|
|
|
|
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false);
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-03 12:49:24 +00:00
|
|
|
|
}
|