MonitoredSpec does not apply to searching

Fixed an issue where search specs weren't applied
This commit is contained in:
Mark McDowall 2013-08-06 20:18:05 -07:00
parent cd7a8bae78
commit f9092e95c2
25 changed files with 123 additions and 145 deletions

View File

@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeFalse();
@ -115,8 +115,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
{
parseResultSingle.Series = series60minutes;
parseResultSingle.Report.Size = 1.Gigabytes();
@ -126,9 +124,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeFalse();
}
@ -136,8 +132,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
{
parseResultMulti.Series = series30minutes;
parseResultMulti.Report.Size = 184572800;
@ -148,7 +142,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultMulti);
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
result.Should().BeTrue();
@ -157,8 +151,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
{
parseResultMulti.Series = series60minutes;
parseResultMulti.Report.Size = 368572800;
@ -169,7 +161,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultMulti);
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
result.Should().BeTrue();
@ -178,8 +170,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
{
parseResultMulti.Series = series30minutes;
parseResultMulti.Report.Size = 1.Gigabytes();
@ -190,7 +180,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultMulti);
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
result.Should().BeFalse();
@ -199,8 +189,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
{
parseResultMulti.Series = series60minutes;
parseResultMulti.Report.Size = 10.Gigabytes();
@ -211,7 +199,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(false);
bool result = Subject.IsSatisfiedBy(parseResultMulti);
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
result.Should().BeFalse();
@ -220,8 +208,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_true_single_episode_first_30_minute()
{
parseResultSingle.Series = series30minutes;
parseResultSingle.Report.Size = 184572800;
@ -232,7 +218,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -241,8 +227,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_true_single_episode_first_60_minute()
{
parseResultSingle.Series = series60minutes;
parseResultSingle.Report.Size = 368572800;
@ -253,7 +237,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -262,8 +246,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void IsAcceptableSize_false_single_episode_first_30_minute()
{
parseResultSingle.Series = series30minutes;
parseResultSingle.Report.Size = 1.Gigabytes();
@ -274,7 +256,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeFalse();
@ -295,7 +277,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeFalse();
@ -317,7 +299,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -339,7 +321,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -363,7 +345,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(true);
bool result = Subject.IsSatisfiedBy(parseResultSingle);
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
result.Should().BeTrue();
@ -377,7 +359,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.RAWHD, false) },
};
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
}
@ -389,7 +371,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.Unknown, false) },
};
Subject.IsSatisfiedBy(parseResult).Should().BeFalse();
Subject.IsSatisfiedBy(parseResult, null).Should().BeFalse();
Mocker.GetMock<IQualitySizeService>().Verify(c=>c.Get(It.IsAny<int>()),Times.Never());

View File

@ -37,23 +37,23 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_fail2 = new Mock<IDecisionEngineSpecification>();
_fail3 = new Mock<IDecisionEngineSpecification>();
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(true);
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(true);
_pass1.Setup(c => c.RejectionReason).Returns("_pass1");
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(true);
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(true);
_pass2.Setup(c => c.RejectionReason).Returns("_pass2");
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(true);
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(true);
_pass3.Setup(c => c.RejectionReason).Returns("_pass3");
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(false);
_fail1.Setup(c => c.RejectionReason).Returns("_fail1");
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(false);
_fail2.Setup(c => c.RejectionReason).Returns("_fail2");
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(false);
_fail3.Setup(c => c.RejectionReason).Returns("_fail3");
_reports = new List<ReportInfo> { new ReportInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } };
@ -61,7 +61,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>()))
.Returns(_remoteEpisode);
}
private void GivenSpecifications(params Mock<IDecisionEngineSpecification>[] mocks)
@ -76,15 +75,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.GetRssDecision(_reports).ToList();
_fail1.Verify(c => c.IsSatisfiedBy(_remoteEpisode), Times.Once());
_fail2.Verify(c => c.IsSatisfiedBy(_remoteEpisode), Times.Once());
_fail3.Verify(c => c.IsSatisfiedBy(_remoteEpisode), Times.Once());
_pass1.Verify(c => c.IsSatisfiedBy(_remoteEpisode), Times.Once());
_pass2.Verify(c => c.IsSatisfiedBy(_remoteEpisode), Times.Once());
_pass3.Verify(c => c.IsSatisfiedBy(_remoteEpisode), Times.Once());
_fail1.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once());
_fail2.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once());
_fail3.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once());
_pass1.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once());
_pass2.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once());
_pass3.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once());
}
[Test]
public void should_return_rejected_if_single_specs_fail()
{
@ -124,7 +122,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
result.Single().Rejections.Should().HaveCount(3);
}
[Test]
public void should_not_attempt_to_map_episode_if_not_parsable()
{
@ -135,9 +132,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
results.Should().BeEmpty();
}
@ -151,14 +148,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
results.Should().BeEmpty();
}
[Test]
public void should_not_attempt_to_make_decision_if_series_is_unknown()
{
@ -168,13 +164,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.GetRssDecision(_reports);
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
}
[Test]
public void broken_report_shouldnt_blowup_the_process()
{
@ -197,7 +191,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
ExceptionVerification.ExpectedErrors(3);
}
[Test]
public void should_return_unknown_series_rejection_if_series_is_unknown()
{
@ -208,8 +201,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var result = Subject.GetRssDecision(_reports);
result.Should().HaveCount(1);
}
}
}

View File

@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
WithEnglishRelease();
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult, null).Should().BeTrue();
}
[Test]
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
WithGermanRelease();
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult).Should().BeFalse();
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult, null).Should().BeFalse();
}
}
}

View File

@ -2,7 +2,7 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Test.Framework;
@ -63,50 +63,44 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void setup_should_return_monitored_episode_should_return_true()
{
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
[Test]
public void not_monitored_series_should_be_skipped()
{
_fakeSeries.Monitored = false;
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse();
}
[Test]
public void only_episode_not_monitored_should_return_false()
{
WithFirstEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse();
}
[Test]
public void both_episodes_not_monitored_should_return_false()
{
WithFirstEpisodeUnmonitored();
WithSecondEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse();
}
[Test]
public void only_first_episode_not_monitored_should_return_monitored()
{
WithFirstEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
[Test]
public void only_second_episode_not_monitored_should_return_monitored()
{
WithSecondEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
}
}

View File

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_be_true_when_restrictions_are_empty()
{
Subject.IsSatisfiedBy(_parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(_parseResult, null).Should().BeTrue();
}
[TestCase("KYR")]
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_be_false_when_nzb_contains_a_restricted_term(string restrictions)
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns(restrictions);
Subject.IsSatisfiedBy(_parseResult).Should().BeFalse();
Subject.IsSatisfiedBy(_parseResult, null).Should().BeFalse();
}
[TestCase("NotReal")]
@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_be_true_when_nzb_does_not_contain_a_restricted_term(string restrictions)
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns(restrictions);
Subject.IsSatisfiedBy(_parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(_parseResult, null).Should().BeTrue();
}
}
}

View File

@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
remoteEpisode.Series.QualityProfile.Value.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
Subject.IsSatisfiedBy(remoteEpisode).Should().BeTrue();
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeTrue();
}
[Test, TestCaseSource("DeniedTestCases")]
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
remoteEpisode.Series.QualityProfile.Value.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
Subject.IsSatisfiedBy(remoteEpisode).Should().BeFalse();
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeFalse();
}
}
}

View File

@ -50,35 +50,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void unlimited_retention_should_return_true()
{
WithUnlimitedRetention();
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
}
[Test]
public void longer_retention_should_return_true()
{
WithLongRetention();
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
}
[Test]
public void equal_retention_should_return_true()
{
WithEqualRetention();
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
}
[Test]
public void shorter_retention_should_return_false()
{
WithShortRetention();
Subject.IsSatisfiedBy(parseResult).Should().BeFalse();
Subject.IsSatisfiedBy(parseResult, null).Should().BeFalse();
}
[Test]
public void zeroDay_report_should_return_true()
{
WithUnlimitedRetention();
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
}
}
}

View File

@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_return_true_if_episode_has_no_existing_file()
{
parseResultSingle.Episodes.ForEach(c => c.EpisodeFileId = 0);
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeTrue();
_upgradeDisk.IsSatisfiedBy(parseResultSingle, null).Should().BeTrue();
}
[Test]
@ -78,14 +78,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
parseResultSingle.Episodes = new List<Episode>();
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeTrue();
_upgradeDisk.IsSatisfiedBy(parseResultSingle, null).Should().BeTrue();
}
[Test]
public void should_be_upgradable_if_only_episode_is_upgradable()
{
WithFirstFileUpgradable();
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeTrue();
_upgradeDisk.IsSatisfiedBy(parseResultSingle, null).Should().BeTrue();
}
[Test]
@ -93,27 +93,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
WithFirstFileUpgradable();
WithSecondFileUpgradable();
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeTrue();
_upgradeDisk.IsSatisfiedBy(parseResultMulti, null).Should().BeTrue();
}
[Test]
public void should_be_not_upgradable_if_both_episodes_are_not_upgradable()
{
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultMulti, null).Should().BeFalse();
}
[Test]
public void should_be_not_upgradable_if_only_first_episodes_is_upgradable()
{
WithFirstFileUpgradable();
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultMulti, null).Should().BeFalse();
}
[Test]
public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
{
WithSecondFileUpgradable();
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultMulti, null).Should().BeFalse();
}
[Test]
@ -121,28 +121,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
firstFile.Quality = new QualityModel(Quality.WEBDL1080p);
parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p, false);
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultSingle, null).Should().BeFalse();
}
[Test]
public void should_return_false_when_episodeFile_was_added_more_than_7_days_ago()
{
firstFile.DateAdded = DateTime.Today.AddDays(-30);
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultSingle, null).Should().BeFalse();
}
[Test]
public void should_return_false_when_first_episodeFile_was_added_more_than_7_days_ago()
{
firstFile.DateAdded = DateTime.Today.AddDays(-30);
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultMulti, null).Should().BeFalse();
}
[Test]
public void should_return_false_when_second_episodeFile_was_added_more_than_7_days_ago()
{
secondFile.DateAdded = DateTime.Today.AddDays(-30);
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
_upgradeDisk.IsSatisfiedBy(parseResultMulti, null).Should().BeFalse();
}
}
}

View File

@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_be_upgradable_if_only_episode_is_upgradable()
{
WithFirstReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultSingle).Should().BeTrue();
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue();
}
[Test]
@ -88,27 +88,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
WithFirstReportUpgradable();
WithSecondReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
[Test]
public void should_not_be_upgradable_if_both_episodes_are_not_upgradable()
{
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse();
}
[Test]
public void should_be_not_upgradable_if_only_first_episodes_is_upgradable()
{
WithFirstReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse();
}
[Test]
public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
{
WithSecondReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse();
}
[Test]
@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(1)).Returns(_upgradableQuality);
_upgradeHistory.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse();
}
}
}

View File

@ -36,7 +36,7 @@ namespace NzbDrone.Core.DecisionEngine
public List<DownloadDecision> GetSearchDecision(IEnumerable<ReportInfo> reports, SearchCriteriaBase searchCriteriaBase)
{
return GetDecisions(reports).ToList();
return GetDecisions(reports, searchCriteriaBase).ToList();
}
private IEnumerable<DownloadDecision> GetDecisions(IEnumerable<ReportInfo> reports, SearchCriteriaBase searchCriteria = null)
@ -94,17 +94,8 @@ namespace NzbDrone.Core.DecisionEngine
throw new InvalidOperationException("[Need Rejection Text]");
}
var searchSpecification = spec as IDecisionEngineSearchSpecification;
if (searchSpecification != null && searchCriteriaBase != null)
{
if (!searchSpecification.IsSatisfiedBy(remoteEpisode, searchCriteriaBase))
{
return spec.RejectionReason;
}
}
var generalSpecification = spec as IDecisionEngineSpecification;
if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(remoteEpisode))
if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(remoteEpisode, searchCriteriaBase))
{
return spec.RejectionReason;
}

View File

@ -1,9 +1,10 @@
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine
{
public interface IDecisionEngineSpecification : IRejectWithReason
{
bool IsSatisfiedBy(RemoteEpisode subject);
bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase);
}
}

View File

@ -1,5 +1,6 @@
using System.Linq;
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
@ -24,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
get { return "File size too big or small"; }
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
_logger.Trace("Beginning size check for: {0}", subject);

View File

@ -1,4 +1,5 @@
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
@ -21,7 +22,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
_logger.Trace("Checking if report meets language requirements. {0}", subject.ParsedEpisodeInfo.Language);
if (subject.ParsedEpisodeInfo.Language != Language.English)

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Download;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
@ -27,7 +28,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public bool IsSatisfiedBy(RemoteEpisode subject)
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
var downloadClient = _downloadClientProvider.GetDownloadClient();

View File

@ -1,6 +1,7 @@
using System;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
@ -24,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
_logger.Trace("Checking if release contains any restricted terms: {0}", subject);

View File

@ -1,4 +1,5 @@
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
@ -20,7 +21,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
_logger.Trace("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality);
if (!subject.Series.QualityProfile.Value.Allowed.Contains(subject.ParsedEpisodeInfo.Quality.Quality))

View File

@ -1,5 +1,6 @@
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
@ -24,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
var age = subject.Report.Age;

View File

@ -1,8 +1,9 @@
using System.Linq;
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
{
public class MonitoredEpisodeSpecification : IDecisionEngineSpecification
{
@ -21,8 +22,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
if (searchCriteriaBase != null)
{
_logger.Trace("Skipping monitored check during search");
return true;
}
if (!subject.Series.Monitored)
{
_logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series);

View File

@ -5,7 +5,7 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public class DailyEpisodeMatchSpecification : IDecisionEngineSearchSpecification
public class DailyEpisodeMatchSpecification : IDecisionEngineSpecification
{
private readonly Logger _logger;
private readonly IEpisodeService _episodeService;
@ -25,6 +25,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
}
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
{
if (searchCriteriaBase == null)
{
return true;
}
var dailySearchSpec = searchCriteriaBase as DailyEpisodeSearchCriteria;
if (dailySearchSpec == null) return true;

View File

@ -1,10 +0,0 @@
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public interface IDecisionEngineSearchSpecification : IRejectWithReason
{
bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase);
}
}

View File

@ -4,7 +4,7 @@ using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public class SeasonMatchSpecification : IDecisionEngineSearchSpecification
public class SeasonMatchSpecification : IDecisionEngineSpecification
{
private readonly Logger _logger;
@ -23,6 +23,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
{
if (searchCriteriaBase == null)
{
return true;
}
var singleEpisodeSpec = searchCriteriaBase as SeasonSearchCriteria;
if (singleEpisodeSpec == null) return true;

View File

@ -5,7 +5,7 @@ using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSearchSpecification
public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSpecification
{
private readonly Logger _logger;
@ -24,6 +24,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
{
if (searchCriteriaBase == null)
{
return true;
}
var singleEpisodeSpec = searchCriteriaBase as SingleEpisodeSearchCriteria;
if (singleEpisodeSpec == null) return true;

View File

@ -1,6 +1,7 @@
using System;
using System.Linq;
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
@ -24,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
{

View File

@ -1,5 +1,6 @@
using NLog;
using NzbDrone.Core.History;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
@ -25,7 +26,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
foreach (var episode in subject.Episodes)
{

View File

@ -177,12 +177,11 @@
<Compile Include="DecisionEngine\Specifications\NotRestrictedReleaseSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\SeasonMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\DailyEpisodeMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\IDecisionEngineSearchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" />
<Compile Include="DecisionEngine\DownloadDecisionMaker.cs" />
<Compile Include="DecisionEngine\Specifications\NotInQueueSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\LanguageSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\MonitoredEpisodeSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\RssSync\MonitoredEpisodeSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\QualityAllowedByProfileSpecification.cs" />
<Compile Include="DecisionEngine\QualityUpgradableSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeSearchMatchSpecification.cs" />