2011-05-27 04:12:28 +02:00
|
|
|
|
using System;
|
2012-04-19 09:41:34 +02:00
|
|
|
|
using System.Globalization;
|
2011-05-27 04:12:28 +02:00
|
|
|
|
using System.IO;
|
2012-02-27 21:36:04 +01:00
|
|
|
|
using System.Linq;
|
2011-05-27 04:12:28 +02:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.ServiceModel.Syndication;
|
2012-04-19 09:41:34 +02:00
|
|
|
|
using System.Threading;
|
2011-05-27 04:12:28 +02:00
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using FluentAssertions;
|
2011-05-27 04:12:28 +02:00
|
|
|
|
using Moq;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2012-02-11 01:48:20 +01:00
|
|
|
|
using NzbDrone.Common;
|
2011-05-28 21:23:35 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
2011-05-27 04:12:28 +02:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-10-21 01:42:17 +02:00
|
|
|
|
using NzbDrone.Core.Test.ProviderTests;
|
2011-10-24 07:54:09 +02:00
|
|
|
|
using NzbDrone.Test.Common;
|
2011-05-27 04:12:28 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-11-13 08:27:16 +01:00
|
|
|
|
public class IndexerTests : CoreTest
|
2011-05-27 04:12:28 +02:00
|
|
|
|
{
|
2012-02-11 06:35:14 +01:00
|
|
|
|
[TestCase("nzbsrus.xml")]
|
|
|
|
|
[TestCase("newzbin.xml")]
|
|
|
|
|
[TestCase("nzbmatrix.xml")]
|
2012-02-27 21:36:04 +01:00
|
|
|
|
[TestCase("newznab.xml")]
|
2012-04-14 08:44:34 +02:00
|
|
|
|
[TestCase("wombles.xml")]
|
|
|
|
|
[TestCase("filesharingtalk.xml")]
|
2012-04-15 01:37:36 +02:00
|
|
|
|
[TestCase("nzbindex.xml")]
|
2012-04-15 01:50:08 +02:00
|
|
|
|
[TestCase("nzbclub.xml")]
|
2012-02-11 06:35:14 +01:00
|
|
|
|
public void parse_feed_xml(string fileName)
|
2011-05-27 04:12:28 +02:00
|
|
|
|
{
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
2011-07-08 05:27:11 +02:00
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var mockIndexer = Mocker.Resolve<MockIndexer>();
|
2011-05-27 04:12:28 +02:00
|
|
|
|
var parseResults = mockIndexer.FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
var Uri = new Uri(episodeParseResult.NzbUrl);
|
2011-06-02 23:06:46 +02:00
|
|
|
|
Uri.PathAndQuery.Should().NotContain("//");
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-02 23:06:46 +02:00
|
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
|
parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name);
|
2012-01-20 07:35:10 +01:00
|
|
|
|
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
2012-02-18 22:18:00 +01:00
|
|
|
|
parseResults.Should().OnlyContain(s => s.Age >= 0);
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-01 02:37:36 +01:00
|
|
|
|
private void WithConfiguredIndexers()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbMatrixApiKey).Returns("MockedConfigValue");
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbMatrixUsername).Returns("MockedConfigValue");
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NewzbinUsername).Returns("MockedConfigValue");
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NewzbinPassword).Returns("MockedConfigValue");
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue");
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue");
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
|
2012-05-03 00:42:21 +02:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
|
2012-02-01 02:37:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-10 21:52:29 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void newzbin_parses_languae()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
2011-07-10 21:52:29 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-07-10 21:52:29 +02:00
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\newbin_none_english.xml"));
|
|
|
|
|
|
2011-10-17 05:51:15 +02:00
|
|
|
|
|
2011-07-10 21:52:29 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var newzbin = Mocker.Resolve<Newzbin>();
|
2011-07-10 21:52:29 +02:00
|
|
|
|
var parseResults = newzbin.FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
var Uri = new Uri(episodeParseResult.NzbUrl);
|
|
|
|
|
Uri.PathAndQuery.Should().NotContain("//");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
|
parseResults.Should().NotContain(e => e.Language == LanguageType.English);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-27 04:12:28 +02:00
|
|
|
|
[Test]
|
2011-06-03 03:15:19 +02:00
|
|
|
|
public void newzbin_rss_fetch()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
{
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-07-08 05:27:11 +02:00
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-07-02 20:41:23 +02:00
|
|
|
|
.SetupGet(c => c.NewzbinUsername)
|
|
|
|
|
.Returns("nzbdrone");
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-07-02 20:41:23 +02:00
|
|
|
|
.SetupGet(c => c.NewzbinPassword)
|
|
|
|
|
.Returns("smartar39865");
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var newzbinProvider = Mocker.Resolve<Newzbin>();
|
2011-05-27 04:12:28 +02:00
|
|
|
|
var parseResults = newzbinProvider.FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
var Uri = new Uri(episodeParseResult.NzbUrl);
|
2011-06-02 23:06:46 +02:00
|
|
|
|
Uri.PathAndQuery.Should().NotContain("//");
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-02 23:06:46 +02:00
|
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
|
parseResults.Should().OnlyContain(s => s.Indexer == newzbinProvider.Name);
|
2012-01-20 07:35:10 +01:00
|
|
|
|
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
2011-06-02 23:06:46 +02:00
|
|
|
|
|
2012-01-23 05:29:09 +01:00
|
|
|
|
Mark500Inconclusive();
|
2011-07-02 20:41:23 +02:00
|
|
|
|
ExceptionVerification.IgnoreWarns();
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 02:36:16 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void custome_parser_partial_success()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
{
|
2012-10-14 02:36:16 +02:00
|
|
|
|
const string title = "Adventure.Inc.S03E19.DVDRip.XviD-OSiTV";
|
|
|
|
|
const int season = 3;
|
|
|
|
|
const int episode = 19;
|
|
|
|
|
var quality = QualityTypes.DVD;
|
|
|
|
|
|
2011-05-27 04:12:28 +02:00
|
|
|
|
const string summary = "My fake summary";
|
|
|
|
|
|
2011-07-08 05:27:11 +02:00
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
var fakeRssItem = Builder<SyndicationItem>.CreateNew()
|
|
|
|
|
.With(c => c.Title = new TextSyndicationContent(title))
|
|
|
|
|
.With(c => c.Summary = new TextSyndicationContent(summary))
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var result = Mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
|
2011-05-27 04:12:28 +02:00
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(result);
|
2011-05-28 21:23:35 +02:00
|
|
|
|
Assert.AreEqual(LanguageType.Finnish, result.Language);
|
2011-05-27 04:12:28 +02:00
|
|
|
|
Assert.AreEqual(season, result.SeasonNumber);
|
|
|
|
|
Assert.AreEqual(episode, result.EpisodeNumbers[0]);
|
2012-10-14 02:36:16 +02:00
|
|
|
|
Assert.AreEqual(quality, result.Quality.Quality);
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-02 23:06:46 +02:00
|
|
|
|
[TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")]
|
2011-05-27 04:12:28 +02:00
|
|
|
|
public void custome_parser_full_parse(string title)
|
|
|
|
|
{
|
|
|
|
|
const string summary = "My fake summary";
|
|
|
|
|
|
2011-07-08 05:27:11 +02:00
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
var fakeRssItem = Builder<SyndicationItem>.CreateNew()
|
|
|
|
|
.With(c => c.Title = new TextSyndicationContent(title))
|
|
|
|
|
.With(c => c.Summary = new TextSyndicationContent(summary))
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var result = Mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
|
2011-05-27 04:12:28 +02:00
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(result);
|
2011-05-28 21:23:35 +02:00
|
|
|
|
Assert.AreEqual(LanguageType.Finnish, result.Language);
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void downloadFeed()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-05-27 04:12:28 +02:00
|
|
|
|
|
2011-07-08 05:27:11 +02:00
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 04:12:28 +02:00
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<TestUrlIndexer>().FetchRss();
|
2011-05-27 04:12:28 +02:00
|
|
|
|
|
2012-01-23 05:29:09 +01:00
|
|
|
|
Mark500Inconclusive();
|
2012-01-23 05:34:30 +01:00
|
|
|
|
ExceptionVerification.IgnoreWarns();
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-02 20:41:23 +02:00
|
|
|
|
[TestCase("simpsons", 21, 23)]
|
2011-07-04 01:04:57 +02:00
|
|
|
|
[TestCase("Hawaii Five-0 (2010)", 1, 1)]
|
2011-12-10 20:22:47 +01:00
|
|
|
|
[TestCase("In plain Sight", 1, 11, Ignore = true)]
|
2011-06-25 03:20:52 +02:00
|
|
|
|
public void newzbin_search_returns_valid_results(string title, int season, int episode)
|
2011-06-03 03:15:19 +02:00
|
|
|
|
{
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-06-03 03:15:19 +02:00
|
|
|
|
.SetupGet(c => c.NewzbinUsername)
|
|
|
|
|
.Returns("nzbdrone");
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-06-03 03:15:19 +02:00
|
|
|
|
.SetupGet(c => c.NewzbinPassword)
|
|
|
|
|
.Returns("smartar39865");
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-06-03 03:15:19 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var result = Mocker.Resolve<Newzbin>().FetchEpisode(title, season, episode);
|
2011-06-03 03:15:19 +02:00
|
|
|
|
|
2012-01-23 05:29:09 +01:00
|
|
|
|
Mark500Inconclusive();
|
2011-06-03 03:15:19 +02:00
|
|
|
|
result.Should().NotBeEmpty();
|
2011-05-27 08:03:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-27 06:33:24 +01:00
|
|
|
|
[TestCase("simpsons", 21, 23)]
|
|
|
|
|
[TestCase("The walking dead", 2, 10)]
|
|
|
|
|
public void nzbmatrix_search_returns_valid_results(string title, int season, int episode)
|
2011-06-04 07:32:55 +02:00
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
2011-06-04 07:32:55 +02:00
|
|
|
|
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-06-04 07:32:55 +02:00
|
|
|
|
|
2012-02-27 06:33:24 +01:00
|
|
|
|
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode(title, season, episode);
|
2011-06-04 07:32:55 +02:00
|
|
|
|
|
2012-01-23 05:29:09 +01:00
|
|
|
|
Mark500Inconclusive();
|
2011-10-17 05:51:15 +02:00
|
|
|
|
|
2011-06-04 07:32:55 +02:00
|
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
|
}
|
2011-05-27 08:03:57 +02:00
|
|
|
|
|
2011-06-04 07:32:55 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void nzbmatrix_multi_word_search_returns_valid_results()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
2011-06-04 07:32:55 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-06-04 07:32:55 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Blue Bloods", 1, 19);
|
2011-06-04 07:32:55 +02:00
|
|
|
|
|
2012-01-23 05:29:09 +01:00
|
|
|
|
Mark500Inconclusive();
|
2011-10-17 05:51:15 +02:00
|
|
|
|
|
2011-06-04 07:32:55 +02:00
|
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
|
}
|
2011-07-04 00:32:36 +02:00
|
|
|
|
|
|
|
|
|
[TestCase("hawaii five-0 (2010)", "hawaii+five+0+2010")]
|
|
|
|
|
[TestCase("this& that", "this+that")]
|
|
|
|
|
[TestCase("this& that", "this+that")]
|
2012-02-11 09:09:28 +01:00
|
|
|
|
[TestCase("grey's anatomy", "grey+s+anatomy")]
|
2011-07-04 00:32:36 +02:00
|
|
|
|
public void get_query_title(string raw, string clean)
|
|
|
|
|
{
|
2012-02-11 09:09:28 +01:00
|
|
|
|
var mock = new Mock<IndexerBase>();
|
2012-02-27 06:33:24 +01:00
|
|
|
|
mock.CallBase = true;
|
2012-02-11 09:09:28 +01:00
|
|
|
|
var result = mock.Object.GetQueryTitle(raw);
|
|
|
|
|
result.Should().Be(clean);
|
|
|
|
|
}
|
2011-07-04 00:32:36 +02:00
|
|
|
|
|
2012-02-11 09:09:28 +01:00
|
|
|
|
[TestCase("hawaii five-0 (2010)", "hawaii+five+0+2010")]
|
|
|
|
|
[TestCase("this& that", "this+that")]
|
|
|
|
|
[TestCase("this& that", "this+that")]
|
|
|
|
|
[TestCase("grey's anatomy", "greys+anatomy")]
|
|
|
|
|
public void get_query_title_nzbmatrix_should_replace_apostrophe_with_empty_string(string raw, string clean)
|
|
|
|
|
{
|
|
|
|
|
var result = Mocker.Resolve<NzbMatrix>().GetQueryTitle(raw);
|
2011-07-04 00:32:36 +02:00
|
|
|
|
result.Should().Be(clean);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-14 04:25:33 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void size_newzbin()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 04:25:33 +02:00
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
|
2011-09-14 04:25:33 +02:00
|
|
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
|
parseResults[0].Size.Should().Be(1295620506);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void size_nzbmatrix()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
2011-09-14 04:25:33 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 04:25:33 +02:00
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbmatrix.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var parseResults = Mocker.Resolve<NzbMatrix>().FetchRss();
|
2011-09-14 04:25:33 +02:00
|
|
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
|
parseResults[0].Size.Should().Be(1331439862);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void size_nzbsrus()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
2011-09-14 04:25:33 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 04:25:33 +02:00
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsrus.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
|
var parseResults = Mocker.Resolve<NzbsRUs>().FetchRss();
|
2011-09-14 04:25:33 +02:00
|
|
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
|
parseResults[0].Size.Should().Be(1793148846);
|
|
|
|
|
}
|
2011-11-21 04:49:04 +01:00
|
|
|
|
|
2012-02-27 21:36:04 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void size_newznab()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
var newznabDefs = Builder<NewznabDefinition>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(n => n.ApiKey = String.Empty)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<NewznabProvider>().Setup(s => s.Enabled()).Returns(newznabDefs.ToList());
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newznab.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var parseResults = Mocker.Resolve<Newznab>().FetchRss();
|
|
|
|
|
|
|
|
|
|
parseResults[0].Size.Should().Be(1183105773);
|
|
|
|
|
}
|
2012-01-21 20:36:22 +01:00
|
|
|
|
|
2012-04-15 01:37:36 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void size_nzbindex()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2012-10-15 04:36:31 +02:00
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet", It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbindex.xml"));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=", It.IsAny<NetworkCredential>()))
|
2012-04-15 01:37:36 +02:00
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbindex.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbIndex>().FetchRss();
|
|
|
|
|
|
|
|
|
|
parseResults[0].Size.Should().Be(587328389);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-15 01:50:08 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void size_nzbclub()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2012-10-15 04:36:31 +02:00
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet", It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbclub.xml"));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=", It.IsAny<NetworkCredential>()))
|
2012-04-15 01:50:08 +02:00
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbclub.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbClub>().FetchRss();
|
|
|
|
|
|
2012-10-15 04:36:31 +02:00
|
|
|
|
parseResults.Should().HaveCount(2);
|
2012-04-15 01:50:08 +02:00
|
|
|
|
parseResults[0].Size.Should().Be(2652142305);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-21 20:36:22 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void Server_Unavailable_503_should_not_log_exception()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Throws(new WebException("503"));
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<NzbsRUs>().FetchRss();
|
2012-01-23 04:01:16 +01:00
|
|
|
|
|
2012-01-21 20:36:22 +01:00
|
|
|
|
ExceptionVerification.ExpectedErrors(0);
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void none_503_server_error_should_still_log_error()
|
|
|
|
|
{
|
2012-02-01 02:37:36 +01:00
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
2012-01-21 20:36:22 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Throws(new WebException("some other server error"));
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<NzbsRUs>().FetchRss();
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedErrors(1);
|
|
|
|
|
ExceptionVerification.ExpectedWarns(0);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-01 02:37:36 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void indexer_that_isnt_configured_shouldnt_make_an_http_call()
|
|
|
|
|
{
|
|
|
|
|
Mocker.Resolve<NotConfiguredIndexer>().FetchRss();
|
2012-02-27 06:33:24 +01:00
|
|
|
|
|
2012-02-01 02:37:36 +01:00
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-27 21:36:04 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void newznab_link_should_be_link_to_nzb_not_details()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\newznab.xml"));
|
|
|
|
|
|
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
var mockIndexer = Mocker.Resolve<MockIndexer>();
|
|
|
|
|
var parseResults = mockIndexer.FetchRss();
|
|
|
|
|
|
|
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
|
parseResults.Should().OnlyContain(s => s.NzbUrl.Contains("getnzb"));
|
|
|
|
|
parseResults.Should().NotContain(s => s.NzbUrl.Contains("details"));
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-29 08:53:30 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void nzbmatrix_should_use_age_from_custom()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
var expectedAge = DateTime.Now.Subtract(new DateTime(2011, 4, 25, 15, 6, 58)).Days;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbmatrix.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbMatrix>().FetchRss();
|
|
|
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
|
parseResults[0].Age.Should().Be(expectedAge);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-23 05:29:09 +01:00
|
|
|
|
private static void Mark500Inconclusive()
|
2011-11-21 04:49:04 +01:00
|
|
|
|
{
|
|
|
|
|
ExceptionVerification.MarkInconclusive(typeof(WebException));
|
2012-01-23 05:24:39 +01:00
|
|
|
|
ExceptionVerification.MarkInconclusive("System.Net.WebException");
|
2012-01-23 05:34:30 +01:00
|
|
|
|
ExceptionVerification.MarkInconclusive("(503) Server Unavailable.");
|
2012-02-25 20:57:56 +01:00
|
|
|
|
ExceptionVerification.MarkInconclusive("(500) Internal Server Error.");
|
2011-11-21 04:49:04 +01:00
|
|
|
|
}
|
2012-04-15 01:37:36 +02:00
|
|
|
|
|
2012-04-19 09:41:34 +02:00
|
|
|
|
[TestCase("wombles.xml", "de-de")]
|
|
|
|
|
public void dateTime_should_parse_when_using_other_cultures(string fileName, string culture)
|
|
|
|
|
{
|
|
|
|
|
var currentCulture = Thread.CurrentThread.CurrentCulture;
|
|
|
|
|
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
|
|
|
|
Mocker.GetMock<IndexerProvider>()
|
|
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
|
|
|
|
|
var mockIndexer = Mocker.Resolve<MockIndexer>();
|
|
|
|
|
var parseResults = mockIndexer.FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
var Uri = new Uri(episodeParseResult.NzbUrl);
|
|
|
|
|
Uri.PathAndQuery.Should().NotContain("//");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
|
parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name);
|
|
|
|
|
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
|
|
|
|
parseResults.Should().OnlyContain(s => s.Age >= 0);
|
|
|
|
|
|
|
|
|
|
Thread.CurrentThread.CurrentCulture = currentCulture;
|
|
|
|
|
}
|
2012-05-03 00:42:21 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void NzbsRus_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "nzbsrus.xml";
|
|
|
|
|
const string expectedString = "nzbdetails";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbsRUs>().FetchRss();
|
2012-05-02 21:02:39 +02:00
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
2012-05-03 00:42:21 +02:00
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Newzbin_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "newzbin.xml";
|
|
|
|
|
const string expectedString = "browse";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void NzbMatrix_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "nzbmatrix.xml";
|
|
|
|
|
const string expectedString = "nzb-details";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbMatrix>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Newznab_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "newznab.xml";
|
|
|
|
|
const string expectedString = "/details/";
|
|
|
|
|
|
|
|
|
|
var newznabDefs = Builder<NewznabDefinition>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(n => n.ApiKey = String.Empty)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<NewznabProvider>().Setup(s => s.Enabled()).Returns(newznabDefs.ToList());
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<Newznab>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Wombles_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "wombles.xml";
|
|
|
|
|
const string expectedString = "nzbdetails";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<Wombles>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().BeNull();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void FileSharingTalk_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "filesharingtalk.xml";
|
|
|
|
|
const string expectedString = "/nzbs/tv";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<FileSharingTalk>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void NzbIndex_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "nzbindex.xml";
|
|
|
|
|
const string expectedString = "release";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2012-10-15 04:36:31 +02:00
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet", It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\nzbindex.xml"));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=", It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\nzbindex.xml"));
|
2012-05-03 00:42:21 +02:00
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbIndex>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void NzbClub_NzbInfoUrl_should_contain_information_string()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
const string fileName = "nzbclub.xml";
|
|
|
|
|
const string expectedString = "nzb_view";
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
2012-10-15 04:36:31 +02:00
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet", It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=", It.IsAny<NetworkCredential>()))
|
2012-05-03 00:42:21 +02:00
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
|
|
|
|
|
var parseResults = Mocker.Resolve<NzbClub>().FetchRss();
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
|
{
|
|
|
|
|
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
|
2012-05-02 21:02:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-06 21:10:41 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void releaseGroup_should_use_nfo_filename_for_newzbin()
|
|
|
|
|
{
|
|
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
|
|
|
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
|
parseResults[0].ReleaseGroup.Should().Be("tvp");
|
|
|
|
|
}
|
2012-09-06 17:37:38 +02:00
|
|
|
|
|
|
|
|
|
[TestCase("30 Rock", "30%20Rock")]
|
|
|
|
|
[TestCase("The Office (US)", "Office%20US")]
|
|
|
|
|
[TestCase("Revenge", "Revenge")]
|
|
|
|
|
[TestCase(" Top Gear ", "Top%20Gear")]
|
|
|
|
|
[TestCase("Breaking Bad", "Breaking%20Bad")]
|
|
|
|
|
[TestCase("Top Chef (US)", "Top%20Chef%20US")]
|
|
|
|
|
[TestCase("Castle (2009)", "Castle%202009")]
|
|
|
|
|
public void newznab_GetQueryTitle_should_return_expected_result(string seriesTitle, string expected)
|
|
|
|
|
{
|
|
|
|
|
Mocker.Resolve<Newznab>().GetQueryTitle(seriesTitle).Should().Be(expected);
|
|
|
|
|
}
|
2011-09-14 04:25:33 +02:00
|
|
|
|
}
|
2011-05-27 04:12:28 +02:00
|
|
|
|
}
|