|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.ServiceModel.Syndication;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using AutoMoq;
|
|
|
|
@ -11,6 +12,7 @@ using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
@ -29,7 +31,7 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>()))
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build();
|
|
|
|
@ -47,6 +49,63 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
Assert.IsEmpty(exceptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
[Row("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)]
|
|
|
|
|
public void parse_feed_test_success(string title, int season, int episode, QualityTypes quality)
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var summary = "My fake summary";
|
|
|
|
|
|
|
|
|
|
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build();
|
|
|
|
|
mocker.GetMock<IndexerProvider>()
|
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(c => c.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(Builder<Series>.CreateNew().Build());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeRssItem = Builder<SyndicationItem>.CreateNew()
|
|
|
|
|
.With(c => c.Title = new TextSyndicationContent(title))
|
|
|
|
|
.With(c => c.Summary = new TextSyndicationContent(summary))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var result = mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(result);
|
|
|
|
|
Assert.AreEqual(summary, result.EpisodeTitle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
[Row("Adventure.Inc.DVDRip.XviD-OSiTV")]
|
|
|
|
|
public void parse_feed_test_fail(string title)
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build();
|
|
|
|
|
mocker.GetMock<IndexerProvider>()
|
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeRssItem = Builder<SyndicationItem>.CreateNew()
|
|
|
|
|
.With(c => c.Title = new TextSyndicationContent(title))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var result = mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
|
|
|
|
|
|
|
|
|
|
Assert.IsNull(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void downloadFeed()
|
|
|
|
|
{
|
|
|
|
@ -102,6 +161,11 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
get { return new[] { "www.google.com" }; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override NetworkCredential Credentials
|
|
|
|
|
{
|
|
|
|
|
get { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Mocked Indexer"; }
|
|
|
|
@ -137,4 +201,33 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CustomParserIndexer : IndexerProviderBase
|
|
|
|
|
{
|
|
|
|
|
public CustomParserIndexer(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IndexerProvider indexerProvider, HistoryProvider historyProvider, SabProvider sabProvider)
|
|
|
|
|
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, indexerProvider, historyProvider, sabProvider)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Custom parser"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string[] Urls
|
|
|
|
|
{
|
|
|
|
|
get { return new[] { "http://www.google.com" }; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
return "http://www.google.com";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Model.EpisodeParseResult CustomParser(SyndicationItem item, Model.EpisodeParseResult currentResult)
|
|
|
|
|
{
|
|
|
|
|
currentResult.EpisodeTitle = item.Summary.Text;
|
|
|
|
|
return currentResult;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|