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