Blacklisting will trigger episode search

This commit is contained in:
Mark McDowall
2013-10-23 22:13:04 -07:00
parent 68e40bca29
commit 8520fe3e0c
12 changed files with 197 additions and 48 deletions
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.Download;
@@ -17,9 +18,9 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
public class UpgradeHistorySpecificationFixture : CoreTest<UpgradeHistorySpecification>
public class HistorySpecificationFixture : CoreTest<HistorySpecification>
{
private UpgradeHistorySpecification _upgradeHistory;
private HistorySpecification _upgradeHistory;
private RemoteEpisode _parseResultMulti;
private RemoteEpisode _parseResultSingle;
@@ -31,7 +32,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void Setup()
{
Mocker.Resolve<QualityUpgradableSpecification>();
_upgradeHistory = Mocker.Resolve<UpgradeHistorySpecification>();
_upgradeHistory = Mocker.Resolve<HistorySpecification>();
var singleEpisodeList = new List<Episode> { new Episode { Id = 1, SeasonNumber = 12, EpisodeNumber = 3 } };
var doubleEpisodeList = new List<Episode> {
@@ -81,6 +82,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(2)).Returns(_upgradableQuality);
}
private void GivenSabnzbdDownloadClient()
{
Mocker.GetMock<IProvideDownloadClient>()
.Setup(c => c.GetDownloadClient()).Returns(Mocker.Resolve<SabnzbdClient>());
}
private void GivenMostRecentForEpisode(HistoryEventType eventType)
{
Mocker.GetMock<IHistoryService>().Setup(s => s.MostRecentForEpisode(It.IsAny<int>()))
.Returns(new History.History { EventType = eventType });
}
[Test]
public void should_be_upgradable_if_only_episode_is_upgradable()
{
@@ -135,12 +148,38 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
}
[Test]
public void should_return_true_if_using_sabnzbd()
public void should_return_true_if_using_sabnzbd_and_nothing_in_history()
{
Mocker.GetMock<IProvideDownloadClient>()
.Setup(c => c.GetDownloadClient()).Returns(Mocker.Resolve<SabnzbdClient>());
GivenSabnzbdDownloadClient();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
[Test]
public void should_return_false_if_most_recent_in_history_is_grabbed()
{
GivenSabnzbdDownloadClient();
GivenMostRecentForEpisode(HistoryEventType.Grabbed);
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse();
}
[Test]
public void should_return_true_if_most_recent_in_history_is_failed()
{
GivenSabnzbdDownloadClient();
GivenMostRecentForEpisode(HistoryEventType.DownloadFailed);
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
[Test]
public void should_return_true_if_most_recent_in_history_is_imported()
{
GivenSabnzbdDownloadClient();
GivenMostRecentForEpisode(HistoryEventType.DownloadFolderImported);
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
}
}