|
|
@ -2,12 +2,13 @@ using System.Collections.Generic;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
using NzbDrone.Core.CustomFormats;
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Profiles;
|
|
|
|
using NzbDrone.Core.Profiles;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Test.CustomFormat;
|
|
|
|
using NzbDrone.Core.Test.CustomFormats;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
@ -18,16 +19,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private RemoteMovie _remoteMovie;
|
|
|
|
private RemoteMovie _remoteMovie;
|
|
|
|
|
|
|
|
|
|
|
|
private CustomFormats.CustomFormat _format1;
|
|
|
|
private CustomFormat _format1;
|
|
|
|
private CustomFormats.CustomFormat _format2;
|
|
|
|
private CustomFormat _format2;
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_format1 = new CustomFormats.CustomFormat("Awesome Format");
|
|
|
|
_format1 = new CustomFormat("Awesome Format");
|
|
|
|
_format1.Id = 1;
|
|
|
|
_format1.Id = 1;
|
|
|
|
|
|
|
|
|
|
|
|
_format2 = new CustomFormats.CustomFormat("Cool Format");
|
|
|
|
_format2 = new CustomFormat("Cool Format");
|
|
|
|
_format2.Id = 2;
|
|
|
|
_format2.Id = 2;
|
|
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Movie>.CreateNew()
|
|
|
|
var fakeSeries = Builder<Movie>.CreateNew()
|
|
|
@ -40,13 +41,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
|
|
|
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CustomFormatsFixture.GivenCustomFormats(CustomFormats.CustomFormat.None, _format1, _format2);
|
|
|
|
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None, _format1, _format2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_allow_if_format_is_defined_in_profile()
|
|
|
|
public void should_allow_if_format_is_defined_in_profile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format1 };
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormat> { _format1 };
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
|
|
@ -55,7 +56,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_deny_if_format_is_defined_in_profile()
|
|
|
|
public void should_deny_if_format_is_defined_in_profile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format2 };
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormat> { _format2 };
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
|
|
@ -64,7 +65,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_deny_if_one_format_is_defined_in_profile()
|
|
|
|
public void should_deny_if_one_format_is_defined_in_profile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format2, _format1 };
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormat> { _format2, _format1 };
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
|
|
@ -73,7 +74,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_allow_if_all_format_is_defined_in_profile()
|
|
|
|
public void should_allow_if_all_format_is_defined_in_profile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format2, _format1 };
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormat> { _format2, _format1 };
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
|
|
@ -82,7 +83,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_deny_if_no_format_was_parsed_and_none_not_in_profile()
|
|
|
|
public void should_deny_if_no_format_was_parsed_and_none_not_in_profile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { };
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormat> { };
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
|
|
@ -91,8 +92,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_allow_if_no_format_was_parsed_and_none_in_profile()
|
|
|
|
public void should_allow_if_no_format_was_parsed_and_none_in_profile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { };
|
|
|
|
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormat> { };
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(CustomFormats.CustomFormat.None.Name, _format1.Name, _format2.Name);
|
|
|
|
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(CustomFormat.None.Name, _format1.Name, _format2.Name);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|