single broken doesnt break the whole decision process

pull/6/head
kay.one 12 years ago
parent fe0f88f5d5
commit 6d12a85756

@ -8,6 +8,7 @@ using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@ -159,7 +160,30 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_return_unknow_series_rejectio_if_series_is_unknow()
public void broken_report_shouldnt_blowup_the_process()
{
GivenSpecifications(_pass1);
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>()))
.Throws<TestException>();
_reports = new List<ReportInfo>
{
new ReportInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"},
new ReportInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"},
new ReportInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}
};
Subject.GetRssDecision(_reports);
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>()), Times.Exactly(_reports.Count));
ExceptionVerification.ExpectedErrors(3);
}
[Test]
public void should_return_unknown_series_rejection_if_series_is_unknow()
{
GivenSpecifications(_pass1, _pass2, _pass3);
@ -170,8 +194,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
result.Should().HaveCount(1);
}
}
}

@ -41,6 +41,10 @@ namespace NzbDrone.Core.DecisionEngine
private IEnumerable<DownloadDecision> GetDecisions(IEnumerable<ReportInfo> reports, SearchDefinitionBase searchDefinition = null)
{
foreach (var report in reports)
{
DownloadDecision decision = null;
try
{
var parsedEpisodeInfo = Parser.Parser.ParseTitle(report.Title);
@ -51,14 +55,25 @@ namespace NzbDrone.Core.DecisionEngine
if (remoteEpisode.Series != null)
{
yield return GetDecisionForReport(remoteEpisode, searchDefinition);
decision = GetDecisionForReport(remoteEpisode, searchDefinition);
}
else
{
yield return new DownloadDecision(remoteEpisode, "Unknown Series");
decision = new DownloadDecision(remoteEpisode, "Unknown Series");
}
}
}
catch (Exception e)
{
_logger.ErrorException("Couldn't process report.", e);
}
if (decision != null)
{
yield return decision;
}
}
}
private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchDefinitionBase searchDefinition = null)

@ -2,13 +2,11 @@ using NLog;
using NLog.Config;
using NLog.Targets;
using NUnit.Framework;
using NzbDrone.Common;
namespace NzbDrone.Test.Common
{
public abstract class LoggingTest
{
protected Logger TestLogger = LogManager.GetLogger("TestLogger");
protected static void InitLogging()

@ -97,6 +97,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestException.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="AutoMoq\License.txt" />

Loading…
Cancel
Save