Clean up some warnings

pull/4/head
Mark McDowall 10 years ago
parent 92cff8c4cc
commit 7e89bcca38

@ -1,148 +0,0 @@
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.Test.IndexerSearchTests
{
[TestFixture]
public class EpisodeInfoRefreshedSearchFixture : CoreTest<EpisodeSearchService>
{
private Series _series;
private IList<Episode> _added;
private IList<Episode> _updated;
[SetUp]
public void Setup()
{
_series = Builder<Series>.CreateNew()
.With(s => s.Added = DateTime.UtcNow.AddDays(-7))
.With(s => s.Monitored = true)
.Build();
_added = new List<Episode>();
_updated = new List<Episode>();
}
private void GivenUpdated()
{
_updated.Add(Builder<Episode>.CreateNew().Build());
}
[Test]
public void should_not_search_if_no_episodes_were_upgraded()
{
_added.Add(new Episode());
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
public void should_not_search_if_series_was_added_within_the_last_day()
{
GivenUpdated();
_series.Added = DateTime.UtcNow;
_added.Add(new Episode());
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
public void should_not_search_if_no_episodes_were_added()
{
GivenUpdated();
_updated.Add(new Episode());
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
public void should_not_search_if_air_date_doesnt_have_a_value()
{
GivenUpdated();
_added.Add(new Episode());
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
public void should_not_search_if_episodes_air_in_the_future()
{
GivenUpdated();
_added.Add(new Episode { AirDateUtc = DateTime.UtcNow.AddDays(7) });
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
public void should_not_search_if_series_is_not_monitored()
{
GivenUpdated();
_series.Monitored = false;
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
public void should_not_search_if_episode_is_not_monitored()
{
GivenUpdated();
_added.Add(new Episode { AirDateUtc = DateTime.UtcNow, Monitored = false });
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
VerifyNoSearch();
}
[Test]
[Ignore]
public void should_search_for_a_newly_added_episode()
{
GivenUpdated();
_added.Add(new Episode { AirDateUtc = DateTime.UtcNow, Monitored = true });
Mocker.GetMock<IProcessDownloadDecisions>()
.Setup(s => s.ProcessDecisions(It.IsAny<List<DownloadDecision>>()))
.Returns(new ProcessedDecisions(new List<DownloadDecision>(), new List<DownloadDecision>(), new List<DownloadDecision>()));
Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated));
Mocker.GetMock<ISearchForNzb>()
.Verify(v => v.EpisodeSearch(It.IsAny<Episode>()), Times.Once());
}
private void VerifyNoSearch()
{
Mocker.GetMock<ISearchForNzb>()
.Verify(v => v.EpisodeSearch(It.IsAny<Episode>()), Times.Never());
}
}
}

@ -199,7 +199,6 @@
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedMetadataFilesFixture.cs" />
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedPendingReleasesFixture.cs" />
<Compile Include="Housekeeping\Housekeepers\FixFutureRunScheduledTasksFixture.cs" />
<Compile Include="IndexerSearchTests\EpisodeInfoRefreshedSearchFixture.cs" />
<Compile Include="IndexerSearchTests\SeriesSearchServiceFixture.cs" />
<Compile Include="IndexerSearchTests\NzbSearchServiceFixture.cs" />
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />

@ -1,5 +1,4 @@
using NLog;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
@ -9,8 +8,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{
public class ProtocolSpecification : IDecisionEngineSpecification
{
private readonly IPendingReleaseService _pendingReleaseService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
private readonly IDelayProfileService _delayProfileService;
private readonly Logger _logger;

@ -65,9 +65,9 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
_logger.Debug("NZB Download succeeded, saved to: {0}", nzbFile);
var strmFile = WriteStrmFile(title, nzbFile);
return GetDownloadClientId(strmFile);
return null;
return GetDownloadClientId(strmFile);
}
public bool IsConfigured

@ -23,8 +23,7 @@ namespace NzbDrone.Core.IndexerSearch
public class EpisodeSearchService : IEpisodeSearchService,
IExecute<EpisodeSearchCommand>,
IExecute<MissingEpisodeSearchCommand>,
IHandle<EpisodeInfoRefreshedEvent>
IExecute<MissingEpisodeSearchCommand>
{
private readonly ISearchForNzb _nzbSearchService;
private readonly IProcessDownloadDecisions _processDownloadDecisions;
@ -142,57 +141,5 @@ namespace NzbDrone.Core.IndexerSearch
SearchForMissingEpisodes(missing);
}
public void Handle(EpisodeInfoRefreshedEvent message)
{
//TODO: This should be triggered off of a disk scan, that follows after the refresh so existing files on disk are counted
return;
if (!message.Series.Monitored)
{
_logger.Debug("Series is not monitored");
return;
}
if (message.Updated.Empty() || message.Series.Added.InLastDays(1))
{
_logger.Debug("Appears to be a new series, skipping search.");
return;
}
if (message.Added.Empty())
{
_logger.Debug("No new episodes, skipping search");
return;
}
if (message.Added.None(a => a.AirDateUtc.HasValue))
{
_logger.Debug("No new episodes have an air date");
return;
}
var previouslyAired = message.Added.Where(a => a.AirDateUtc.HasValue && a.AirDateUtc.Value.Before(DateTime.UtcNow.AddDays(1))).ToList();
if (previouslyAired.Empty())
{
_logger.Debug("Newly added episodes all air in the future");
return;
}
foreach (var episode in previouslyAired)
{
if (!episode.Monitored)
{
_logger.Debug("Episode is not monitored");
continue;
}
var decisions = _nzbSearchService.EpisodeSearch(episode);
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
_logger.ProgressInfo("Episode search completed. {0} reports downloaded.", processed.Grabbed.Count);
}
}
}
}

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Rarbg
{

Loading…
Cancel
Save