fixed indexer service, broken test

pull/3113/head
kay.one 12 years ago
parent 385edbf464
commit 5c08e423a5

@ -1,6 +1,4 @@

using System;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;

@ -18,21 +18,21 @@ namespace NzbDrone.Core.Test.IndexerTests
{
public class IndexerServiceFixture : DbTest<IndexerService, IndexerDefinition>
{
private List<Func<IIndexer>> _indexers;
private List<IIndexer> _indexers;
[SetUp]
public void Setup()
{
_indexers = new List<Func<IIndexer>>();
_indexers = new List<IIndexer>();
_indexers.Add(() => new Newznab());
_indexers.Add(() => new Nzbsrus());
_indexers.Add(() => new NzbClub());
_indexers.Add(() => new NzbIndex());
_indexers.Add(() => new Omgwtfnzbs());
_indexers.Add(() => new Wombles());
_indexers.Add(new Newznab());
_indexers.Add(new Nzbsrus());
_indexers.Add(new NzbClub());
_indexers.Add(new NzbIndex());
_indexers.Add(new Omgwtfnzbs());
_indexers.Add(new Wombles());
Mocker.SetConstant<IEnumerable<Func<IIndexer>>>(_indexers);
Mocker.SetConstant<IEnumerable<IIndexer>>(_indexers);
}

@ -19,9 +19,12 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
result.Should().NotBeEmpty();
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title));
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbInfoUrl));
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbUrl));
result.Should().OnlyContain(c => c.Size > 0);
//TODO: uncomment these after moving to restsharp for rss
//result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbInfoUrl));
//result.Should().OnlyContain(c => c.Size > 0);
}
}

@ -28,9 +28,9 @@ namespace NzbDrone.Core.Indexers
private readonly IIndexerRepository _indexerRepository;
private readonly Logger _logger;
private readonly List<Func<IIndexer>> _indexers;
private readonly List<IIndexer> _indexers;
public IndexerService(IIndexerRepository indexerRepository, IEnumerable<Func<IIndexer>> indexers, Logger logger)
public IndexerService(IIndexerRepository indexerRepository, IEnumerable<IIndexer> indexers, Logger logger)
{
_indexerRepository = indexerRepository;
_logger = logger;
@ -75,7 +75,10 @@ namespace NzbDrone.Core.Indexers
private IIndexer GetInstance(IndexerDefinition indexerDefinition)
{
var instance = _indexers.Single(c => c().GetType().Name.Equals(indexerDefinition.Implementation, StringComparison.InvariantCultureIgnoreCase))();
var type = _indexers.Single(c => c.GetType().Name.Equals(indexerDefinition.Implementation, StringComparison.InvariantCultureIgnoreCase)).GetType();
var instance = (IIndexer)Activator.CreateInstance(type);
instance.InstanceDefinition = indexerDefinition;
return instance;
}
@ -86,7 +89,7 @@ namespace NzbDrone.Core.Indexers
if (!All().Any())
{
var definitions = _indexers.SelectMany(indexer => indexer().DefaultDefinitions);
var definitions = _indexers.SelectMany(indexer => indexer.DefaultDefinitions);
_indexerRepository.InsertMany(definitions.ToList());
}
}

@ -22,10 +22,11 @@ namespace NzbDrone.Integration.Test
{
releaseResource.Age.Should().BeGreaterOrEqualTo(-1);
releaseResource.Title.Should().NotBeBlank();
releaseResource.NzbInfoUrl.Should().NotBeBlank();
releaseResource.NzbUrl.Should().NotBeBlank();
releaseResource.SeriesTitle.Should().NotBeBlank();
releaseResource.Size.Should().BeGreaterThan(0);
//TODO: uncomment these after moving to restsharp for rss
//releaseResource.NzbInfoUrl.Should().NotBeBlank();
//releaseResource.Size.Should().BeGreaterThan(0);
return true;
}

Loading…
Cancel
Save