mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using FizzWare.NBuilder;
|
|
using FluentAssertions;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Core.Books;
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
using NzbDrone.Core.Parser.Model;
|
|
using NzbDrone.Core.Profiles.Qualities;
|
|
using NzbDrone.Core.Qualities;
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
{
|
|
[TestFixture]
|
|
|
|
public class QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
|
|
{
|
|
private RemoteBook _remoteBook;
|
|
|
|
public static object[] AllowedTestCases =
|
|
{
|
|
new object[] { Quality.MP3 },
|
|
new object[] { Quality.MP3 },
|
|
new object[] { Quality.MP3 }
|
|
};
|
|
|
|
public static object[] DeniedTestCases =
|
|
{
|
|
new object[] { Quality.FLAC },
|
|
new object[] { Quality.Unknown }
|
|
};
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
var fakeAuthor = Builder<Author>.CreateNew()
|
|
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.MP3.Id })
|
|
.Build();
|
|
|
|
_remoteBook = new RemoteBook
|
|
{
|
|
Author = fakeAuthor,
|
|
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3, new Revision(version: 2)) },
|
|
};
|
|
}
|
|
|
|
[Test]
|
|
[TestCaseSource(nameof(AllowedTestCases))]
|
|
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
|
{
|
|
_remoteBook.ParsedBookInfo.Quality.Quality = qualityType;
|
|
_remoteBook.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3, Quality.MP3, Quality.MP3);
|
|
|
|
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
[TestCaseSource(nameof(DeniedTestCases))]
|
|
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
|
{
|
|
_remoteBook.ParsedBookInfo.Quality.Quality = qualityType;
|
|
_remoteBook.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3, Quality.MP3, Quality.MP3);
|
|
|
|
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
|
}
|
|
}
|
|
}
|