2011-05-22 18:53:21 +02:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
using System;
|
2011-04-19 02:12:06 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2011-04-25 22:21:52 +02:00
|
|
|
|
using System.Net;
|
2011-04-19 02:12:06 +02:00
|
|
|
|
using System.ServiceModel.Syndication;
|
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2011-01-29 07:10:22 +01:00
|
|
|
|
using Moq;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2011-05-20 06:18:51 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
2011-01-29 07:10:22 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-04-04 05:50:12 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-04-29 08:06:13 +02:00
|
|
|
|
using NzbDrone.Core.Providers.ExternalNotification;
|
2011-04-19 02:12:06 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
2011-01-29 07:10:22 +01:00
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-04-25 22:21:52 +02:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2011-05-19 05:55:35 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using FluentAssertions;
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-04-19 02:12:06 +02:00
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-05-19 05:55:35 +02:00
|
|
|
|
public class IndexerProviderTest : TestBase
|
2011-01-29 07:10:22 +01:00
|
|
|
|
{
|
2011-04-19 02:12:06 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void Init_indexer_test()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-18 02:10:33 +02:00
|
|
|
|
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-04-19 02:12:06 +02:00
|
|
|
|
var indexerProvider = mocker.Resolve<IndexerProvider>();
|
2011-05-20 06:21:18 +02:00
|
|
|
|
indexerProvider.InitializeIndexers(new List<IndexerBase> { mocker.Resolve<MockIndexer>() });
|
2011-05-27 04:12:28 +02:00
|
|
|
|
var settings = indexerProvider.GetSettings(typeof(MockIndexer));
|
|
|
|
|
settings.Enable = true;
|
|
|
|
|
indexerProvider.SaveSettings(settings);
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-06-02 23:06:46 +02:00
|
|
|
|
indexerProvider.GetAllISettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
indexerProvider.GetAllISettings().Should().HaveCount(1);
|
|
|
|
|
indexerProvider.GetEnabledIndexers().Should().HaveCount(1);
|
2011-04-22 21:16:52 +02:00
|
|
|
|
}
|
2011-05-26 06:25:59 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
2011-05-27 04:12:28 +02:00
|
|
|
|
public void Init_indexer_with_disabled_job()
|
2011-05-26 06:25:59 +02:00
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-18 02:10:33 +02:00
|
|
|
|
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
2011-05-26 06:25:59 +02:00
|
|
|
|
|
2011-05-27 04:12:28 +02:00
|
|
|
|
//Act
|
|
|
|
|
var indexerProvider = mocker.Resolve<IndexerProvider>();
|
|
|
|
|
indexerProvider.InitializeIndexers(new List<IndexerBase> { mocker.Resolve<MockIndexer>() });
|
|
|
|
|
var settings = indexerProvider.GetSettings(typeof(MockIndexer));
|
|
|
|
|
settings.Enable = false;
|
|
|
|
|
indexerProvider.SaveSettings(settings);
|
2011-05-26 06:25:59 +02:00
|
|
|
|
|
2011-05-27 04:12:28 +02:00
|
|
|
|
//Assert
|
2011-06-02 23:06:46 +02:00
|
|
|
|
|
|
|
|
|
indexerProvider.GetAllISettings().Should().HaveCount(1);
|
|
|
|
|
indexerProvider.GetEnabledIndexers().Should().BeEmpty();
|
2011-05-26 06:25:59 +02:00
|
|
|
|
}
|
2011-04-19 02:12:06 +02:00
|
|
|
|
}
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
2011-05-20 06:21:18 +02:00
|
|
|
|
public class MockIndexer : IndexerBase
|
2011-04-19 02:12:06 +02:00
|
|
|
|
{
|
2011-05-26 06:25:59 +02:00
|
|
|
|
public MockIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
|
|
|
|
|
: base(httpProvider, configProvider)
|
2011-01-29 07:10:22 +01:00
|
|
|
|
{
|
2011-04-19 02:12:06 +02:00
|
|
|
|
}
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
2011-04-21 03:26:13 +02:00
|
|
|
|
protected override string[] Urls
|
2011-04-19 02:12:06 +02:00
|
|
|
|
{
|
|
|
|
|
get { return new[] { "www.google.com" }; }
|
|
|
|
|
}
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
2011-05-26 06:25:59 +02:00
|
|
|
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-25 22:21:52 +02:00
|
|
|
|
protected override NetworkCredential Credentials
|
|
|
|
|
{
|
|
|
|
|
get { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-19 02:12:06 +02:00
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Mocked Indexer"; }
|
|
|
|
|
}
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
|
2011-04-19 02:12:06 +02:00
|
|
|
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
return item.Links[0].Uri.ToString();
|
2011-01-29 07:10:22 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-25 19:48:16 +02:00
|
|
|
|
|
2011-05-20 06:21:18 +02:00
|
|
|
|
public class TestUrlIndexer : IndexerBase
|
2011-04-25 19:48:16 +02:00
|
|
|
|
{
|
2011-05-26 06:25:59 +02:00
|
|
|
|
public TestUrlIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
|
|
|
|
|
: base(httpProvider, configProvider)
|
2011-04-25 19:48:16 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "All Urls"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string[] Urls
|
|
|
|
|
{
|
|
|
|
|
get { return new[] { "http://rss.nzbmatrix.com/rss.php?cat=TV" }; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-26 06:25:59 +02:00
|
|
|
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-25 19:48:16 +02:00
|
|
|
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
return "http://google.com";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 06:21:18 +02:00
|
|
|
|
public class CustomParserIndexer : IndexerBase
|
2011-04-25 22:21:52 +02:00
|
|
|
|
{
|
2011-05-26 06:25:59 +02:00
|
|
|
|
public CustomParserIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
|
|
|
|
|
: base(httpProvider, configProvider)
|
2011-04-25 22:21:52 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Custom parser"; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
|
2011-05-01 10:04:44 +02:00
|
|
|
|
|
2011-04-25 22:21:52 +02:00
|
|
|
|
protected override string[] Urls
|
|
|
|
|
{
|
|
|
|
|
get { return new[] { "http://www.google.com" }; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-26 06:25:59 +02:00
|
|
|
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-25 22:21:52 +02:00
|
|
|
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
return "http://www.google.com";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Model.EpisodeParseResult CustomParser(SyndicationItem item, Model.EpisodeParseResult currentResult)
|
|
|
|
|
{
|
2011-05-20 06:18:51 +02:00
|
|
|
|
if (currentResult == null) currentResult = new EpisodeParseResult();
|
2011-05-28 21:23:35 +02:00
|
|
|
|
currentResult.Language = LanguageType.Finnish;
|
2011-04-25 22:21:52 +02:00
|
|
|
|
return currentResult;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-10 04:44:01 +02:00
|
|
|
|
}
|