2012-01-18 07:45:21 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
|
2012-02-07 05:08:07 +00:00
|
|
|
|
using System.Linq;
|
2012-01-18 07:45:21 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2013-02-27 03:19:22 +00:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-01-18 07:45:21 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-02-19 02:19:38 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2012-01-18 07:45:21 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 02:19:38 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2012-01-18 07:45:21 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-17 05:44:06 +00:00
|
|
|
|
public class UpgradePossibleSpecificationFixture : CoreTest
|
2012-01-18 07:45:21 +00:00
|
|
|
|
{
|
|
|
|
|
private void WithWebdlCutoff()
|
|
|
|
|
{
|
2013-02-27 03:19:22 +00:00
|
|
|
|
var profile = new QualityProfile { Cutoff = Quality.WEBDL720p };
|
|
|
|
|
Mocker.GetMock<QualityProfileService>().Setup(s => s.Get(It.IsAny<int>())).Returns(profile);
|
2012-01-18 07:45:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Series _series;
|
|
|
|
|
private EpisodeFile _episodeFile;
|
|
|
|
|
private Episode _episode;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp()
|
|
|
|
|
{
|
|
|
|
|
_series = Builder<Series>.CreateNew()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_episodeFile = Builder<EpisodeFile>.CreateNew()
|
2013-02-27 03:19:22 +00:00
|
|
|
|
.With(f => f.Quality = Quality.SDTV)
|
2012-01-18 07:45:21 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_episode = Builder<Episode>.CreateNew()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.With(e => e.SeriesId = _series.Id)
|
2012-01-18 07:45:21 +00:00
|
|
|
|
.With(e => e.Series = _series)
|
|
|
|
|
.With(e => e.EpisodeFile = _episodeFile)
|
|
|
|
|
.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsUpgradePossible_should_return_true_if_no_episode_file_exists()
|
|
|
|
|
{
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
2013-02-20 02:05:15 +00:00
|
|
|
|
.With(e => e.EpisodeFile = null)
|
2012-01-18 07:45:21 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(episode);
|
2012-01-18 07:45:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsUpgradePossible_should_return_true_if_current_episode_is_less_than_cutoff()
|
|
|
|
|
{
|
|
|
|
|
WithWebdlCutoff();
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(_episode);
|
2012-01-18 07:45:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsUpgradePossible_should_return_false_if_current_episode_is_equal_to_cutoff()
|
|
|
|
|
{
|
|
|
|
|
WithWebdlCutoff();
|
|
|
|
|
|
2013-02-27 03:19:22 +00:00
|
|
|
|
_episodeFile.Quality = Quality.WEBDL720p;
|
2012-01-18 07:45:21 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(_episode);
|
2012-01-18 07:45:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsUpgradePossible_should_return_false_if_current_episode_is_greater_than_cutoff()
|
|
|
|
|
{
|
|
|
|
|
WithWebdlCutoff();
|
|
|
|
|
|
2013-02-27 03:19:22 +00:00
|
|
|
|
_episodeFile.Quality = Quality.Bluray720p;
|
2012-01-18 07:45:21 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(_episode);
|
2012-01-18 07:45:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|