single broken doesnt break the whole decision process

pull/3113/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);
}
}
}

@ -42,23 +42,38 @@ namespace NzbDrone.Core.DecisionEngine
{
foreach (var report in reports)
{
var parsedEpisodeInfo = Parser.Parser.ParseTitle(report.Title);
DownloadDecision decision = null;
if (parsedEpisodeInfo != null)
try
{
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo);
remoteEpisode.Report = report;
var parsedEpisodeInfo = Parser.Parser.ParseTitle(report.Title);
if (remoteEpisode.Series != null)
if (parsedEpisodeInfo != null)
{
yield return GetDecisionForReport(remoteEpisode, searchDefinition);
}
else
{
yield return new DownloadDecision(remoteEpisode, "Unknown Series");
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo);
remoteEpisode.Report = report;
if (remoteEpisode.Series != null)
{
decision = GetDecisionForReport(remoteEpisode, searchDefinition);
}
else
{
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