2011-04-19 00:12:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.ServiceModel.Syndication;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2011-01-29 06:10:22 +00:00
|
|
|
|
using MbUnit.Framework;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-04-04 03:50:12 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-04-19 00:12:06 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
2011-01-29 06:10:22 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class IndexerProviderTest
|
2011-04-19 00:12:06 +00:00
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
2011-04-19 00:12:06 +00:00
|
|
|
|
public void Download_feed_test()
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-04-19 00:12:06 +00:00
|
|
|
|
var mocker = new AutoMoqer();
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
var xmlReader = XmlReader.Create(File.OpenRead(".\\Files\\Rss\\nzbsorg.xml"));
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadXml(It.IsAny<String>()))
|
|
|
|
|
.Returns(xmlReader);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build();
|
|
|
|
|
mocker.GetMock<IndexerProvider>()
|
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
mocker.Resolve<MockIndexerProvider>().Fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Init_indexer_test()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.SetConstant(MockLib.GetEmptyRepository());
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-04-19 00:12:06 +00:00
|
|
|
|
var indexerProvider = mocker.Resolve<IndexerProvider>();
|
|
|
|
|
indexerProvider.InitializeIndexers(new List<IndexerProviderBase>() { mocker.Resolve<MockIndexerProvider>() });
|
2011-04-22 06:23:29 +00:00
|
|
|
|
var indexers = indexerProvider.All();
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-04-19 00:12:06 +00:00
|
|
|
|
Assert.Count(1, indexers);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
2011-04-19 00:12:06 +00:00
|
|
|
|
}
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
public class MockIndexerProvider : IndexerProviderBase
|
|
|
|
|
{
|
2011-04-22 02:23:31 +00:00
|
|
|
|
public MockIndexerProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IndexerProvider indexerProvider, HistoryProvider historyProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, indexerProvider, historyProvider)
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-04-19 00:12:06 +00:00
|
|
|
|
}
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-04-21 01:26:13 +00:00
|
|
|
|
protected override string[] Urls
|
2011-04-19 00:12:06 +00:00
|
|
|
|
{
|
|
|
|
|
get { return new[] { "www.google.com" }; }
|
|
|
|
|
}
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Mocked Indexer"; }
|
|
|
|
|
}
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
return item.Links[0].Uri.ToString();
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 02:44:01 +00:00
|
|
|
|
}
|