From ada9b944dc7bbcbb2e32ec7d694005ccb9d6b90b Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 6 Aug 2019 22:40:50 -0400 Subject: [PATCH] Fixed: QueueSpecificationFixture Test --- .../QueueSpecificationFixture.cs | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs index 5bc79d72b..45b5af5c6 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs @@ -27,7 +27,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.Resolve(); _movie = Builder.CreateNew() - .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) + .With(e => e.Profile = new Profile { + Items = Qualities.QualityFixture.GetDefaultQualities(), + UpgradeAllowed = true + }) .Build(); _otherMovie = Builder.CreateNew() @@ -47,11 +50,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(new List()); } - private void GivenQueue(IEnumerable remoteEpisodes) + private void GivenQueue(IEnumerable remoteMovies) { - var queue = remoteEpisodes.Select(remoteEpisode => new Queue.Queue + var queue = remoteMovies.Select(remoteMovie => new Queue.Queue { - RemoteMovie = remoteEpisode + RemoteMovie = remoteMovie }); Mocker.GetMock() @@ -67,13 +70,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests } [Test] - public void should_return_true_when_series_doesnt_match() + public void should_return_true_when_movie_doesnt_match() { - var remoteEpisode = Builder.CreateNew() + var remoteMovie = Builder.CreateNew() .With(r => r.Movie = _otherMovie) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteMovie }); Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } @@ -82,7 +85,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _movie.Profile.Value.Cutoff = Quality.Bluray1080p.Id; - var remoteEpisode = Builder.CreateNew() + var remoteMovie = Builder.CreateNew() .With(r => r.Movie = _movie) .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { @@ -90,14 +93,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteMovie }); Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_when_qualities_are_the_same() { - var remoteEpisode = Builder.CreateNew() + var remoteMovie = Builder.CreateNew() .With(r => r.Movie = _movie) .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { @@ -105,7 +108,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteMovie }); Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } @@ -114,7 +117,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _movie.Profile.Value.Cutoff = Quality.Bluray1080p.Id; - var remoteEpisode = Builder.CreateNew() + var remoteMovie = Builder.CreateNew() .With(r => r.Movie = _movie) .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { @@ -122,7 +125,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteMovie }); Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } @@ -131,7 +134,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { _movie.Profile.Value.Cutoff = _remoteMovie.ParsedMovieInfo.Quality.Quality.Id; - var remoteEpisode = Builder.CreateNew() + var remoteMovie = Builder.CreateNew() .With(r => r.Movie = _movie) .With(r => r.ParsedMovieInfo = new ParsedMovieInfo { @@ -139,9 +142,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteMovie }); Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); } + + + [Test] + public void should_return_false_when_quality_is_better_and_upgrade_allowed_is_false_for_quality_profile() + { + _movie.Profile.Value.Cutoff = Quality.Bluray1080p.Id; + _movie.Profile.Value.UpgradeAllowed = false; + + var remoteMovie = Builder.CreateNew() + .With(r => r.Movie = _movie) + .With(r => r.ParsedMovieInfo = new ParsedMovieInfo + { + Quality = new QualityModel(Quality.Bluray1080p) + }) + .Build(); + + GivenQueue(new List { remoteMovie }); + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse(); + } } }