2011-05-27 05:12:28 +03:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Net;
|
|
|
|
using System.ServiceModel.Syndication;
|
2011-11-14 03:22:18 +03:00
|
|
|
|
2011-05-27 05:12:28 +03:00
|
|
|
using FizzWare.NBuilder;
|
2011-06-03 00:06:46 +03:00
|
|
|
using FluentAssertions;
|
2011-05-27 05:12:28 +03:00
|
|
|
using Moq;
|
2011-06-03 00:06:46 +03:00
|
|
|
using NUnit.Framework;
|
2012-02-11 03:48:20 +03:00
|
|
|
using NzbDrone.Common;
|
2011-05-28 22:23:35 +03:00
|
|
|
using NzbDrone.Core.Model;
|
2011-05-27 05:12:28 +03: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 02:42:17 +03:00
|
|
|
using NzbDrone.Core.Test.ProviderTests;
|
2011-10-24 08:54:09 +03:00
|
|
|
using NzbDrone.Test.Common;
|
2011-05-27 05:12:28 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-11-13 10:27:16 +03:00
|
|
|
public class IndexerTests : CoreTest
|
2011-05-27 05:12:28 +03:00
|
|
|
{
|
2011-07-02 21:41:23 +03:00
|
|
|
|
2012-02-11 08:35:14 +03:00
|
|
|
[TestCase("nzbsorg.xml")]
|
|
|
|
[TestCase("nzbsrus.xml")]
|
|
|
|
[TestCase("newzbin.xml")]
|
|
|
|
[TestCase("nzbmatrix.xml")]
|
|
|
|
public void parse_feed_xml(string fileName)
|
2011-05-27 05:12:28 +03:00
|
|
|
{
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-05-27 05:12:28 +03:00
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
|
|
|
|
|
2011-07-08 06:27:11 +03:00
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 05:12:28 +03:00
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
var mockIndexer = Mocker.Resolve<MockIndexer>();
|
2011-05-27 05:12:28 +03:00
|
|
|
var parseResults = mockIndexer.FetchRss();
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
{
|
|
|
|
var Uri = new Uri(episodeParseResult.NzbUrl);
|
2011-06-03 00:06:46 +03:00
|
|
|
Uri.PathAndQuery.Should().NotContain("//");
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-03 00:06:46 +03:00
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name);
|
2012-01-20 09:35:10 +03:00
|
|
|
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
2012-02-19 00:18:00 +03:00
|
|
|
parseResults.Should().OnlyContain(s => s.Age >= 0);
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
2012-02-01 04:37:36 +03: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");
|
|
|
|
}
|
|
|
|
|
2011-07-10 22:52:29 +03:00
|
|
|
[Test]
|
|
|
|
public void newzbin_parses_languae()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
2011-07-10 22:52:29 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-07-10 22:52:29 +03:00
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\newbin_none_english.xml"));
|
|
|
|
|
2011-10-17 06:51:15 +03:00
|
|
|
|
2011-07-10 22:52:29 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
var newzbin = Mocker.Resolve<Newzbin>();
|
2011-07-10 22:52:29 +03: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 05:12:28 +03:00
|
|
|
[Test]
|
2011-06-03 04:15:19 +03:00
|
|
|
public void newzbin_rss_fetch()
|
2011-05-27 05:12:28 +03:00
|
|
|
{
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-07-08 06:27:11 +03:00
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 05:12:28 +03:00
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-07-02 21:41:23 +03:00
|
|
|
.SetupGet(c => c.NewzbinUsername)
|
|
|
|
.Returns("nzbdrone");
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-07-02 21:41:23 +03:00
|
|
|
.SetupGet(c => c.NewzbinPassword)
|
|
|
|
.Returns("smartar39865");
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
var newzbinProvider = Mocker.Resolve<Newzbin>();
|
2011-05-27 05:12:28 +03:00
|
|
|
var parseResults = newzbinProvider.FetchRss();
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in parseResults)
|
|
|
|
{
|
|
|
|
var Uri = new Uri(episodeParseResult.NzbUrl);
|
2011-06-03 00:06:46 +03:00
|
|
|
Uri.PathAndQuery.Should().NotContain("//");
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-03 00:06:46 +03:00
|
|
|
parseResults.Should().NotBeEmpty();
|
|
|
|
parseResults.Should().OnlyContain(s => s.Indexer == newzbinProvider.Name);
|
2012-01-20 09:35:10 +03:00
|
|
|
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
2011-06-03 00:06:46 +03:00
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
Mark500Inconclusive();
|
2011-07-02 21:41:23 +03:00
|
|
|
ExceptionVerification.IgnoreWarns();
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
2011-07-02 21:41:23 +03:00
|
|
|
|
2011-06-03 00:06:46 +03:00
|
|
|
[TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)]
|
2011-05-27 05:12:28 +03:00
|
|
|
public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality)
|
|
|
|
{
|
|
|
|
const string summary = "My fake summary";
|
|
|
|
|
2011-07-08 06:27:11 +03:00
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 05:12:28 +03: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 07:15:53 +03:00
|
|
|
var result = Mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
|
2011-05-27 05:12:28 +03:00
|
|
|
|
|
|
|
Assert.IsNotNull(result);
|
2011-05-28 22:23:35 +03:00
|
|
|
Assert.AreEqual(LanguageType.Finnish, result.Language);
|
2011-05-27 05:12:28 +03:00
|
|
|
Assert.AreEqual(season, result.SeasonNumber);
|
|
|
|
Assert.AreEqual(episode, result.EpisodeNumbers[0]);
|
2011-05-28 22:23:35 +03:00
|
|
|
Assert.AreEqual(quality, result.Quality.QualityType);
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
2011-06-13 07:20:29 +03:00
|
|
|
|
2011-06-03 00:06:46 +03:00
|
|
|
[TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")]
|
2011-05-27 05:12:28 +03:00
|
|
|
public void custome_parser_full_parse(string title)
|
|
|
|
{
|
|
|
|
const string summary = "My fake summary";
|
|
|
|
|
2011-07-08 06:27:11 +03:00
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 05:12:28 +03: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 07:15:53 +03:00
|
|
|
var result = Mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
|
2011-05-27 05:12:28 +03:00
|
|
|
|
|
|
|
Assert.IsNotNull(result);
|
2011-05-28 22:23:35 +03:00
|
|
|
Assert.AreEqual(LanguageType.Finnish, result.Language);
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void downloadFeed()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-05-27 05:12:28 +03:00
|
|
|
|
2011-07-08 06:27:11 +03:00
|
|
|
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<IndexerProvider>()
|
2011-05-27 05:12:28 +03:00
|
|
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
|
|
|
.Returns(fakeSettings);
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<TestUrlIndexer>().FetchRss();
|
2011-05-27 05:12:28 +03:00
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
Mark500Inconclusive();
|
2012-01-23 07:34:30 +03:00
|
|
|
ExceptionVerification.IgnoreWarns();
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|
|
|
|
|
2011-07-04 01:32:36 +03:00
|
|
|
[TestCase("simpsons", 21, 23)]
|
|
|
|
[TestCase("Hawaii Five-0 (2010)", 1, 5)]
|
2011-07-10 22:52:29 +03:00
|
|
|
[TestCase("In plain Sight", 1, 4)]
|
2011-07-04 01:32:36 +03:00
|
|
|
public void nzbsorg_search_returns_valid_results(string title, int season, int episode)
|
2011-05-27 05:12:28 +03:00
|
|
|
{
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-05-27 05:12:28 +03:00
|
|
|
.SetupGet(c => c.NzbsOrgUId)
|
|
|
|
.Returns("43516");
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-05-27 05:12:28 +03:00
|
|
|
.SetupGet(c => c.NzbsOrgHash)
|
|
|
|
.Returns("bc8edb4cc49d4ae440775adec5ac001f");
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-05-27 05:12:28 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
var result = Mocker.Resolve<NzbsOrg>().FetchEpisode(title, season, episode);
|
2012-02-01 04:37:36 +03:00
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
Mark500Inconclusive();
|
2011-10-17 06:51:15 +03:00
|
|
|
|
2011-06-03 00:06:46 +03:00
|
|
|
result.Should().NotBeEmpty();
|
2011-06-03 04:15:19 +03:00
|
|
|
}
|
|
|
|
|
2011-07-02 21:41:23 +03:00
|
|
|
[TestCase("simpsons", 21, 23)]
|
2011-07-04 02:04:57 +03:00
|
|
|
[TestCase("Hawaii Five-0 (2010)", 1, 1)]
|
2011-12-10 22:22:47 +03:00
|
|
|
[TestCase("In plain Sight", 1, 11, Ignore = true)]
|
2011-06-25 04:20:52 +03:00
|
|
|
public void newzbin_search_returns_valid_results(string title, int season, int episode)
|
2011-06-03 04:15:19 +03:00
|
|
|
{
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-06-03 04:15:19 +03:00
|
|
|
.SetupGet(c => c.NewzbinUsername)
|
|
|
|
.Returns("nzbdrone");
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-06-03 04:15:19 +03:00
|
|
|
.SetupGet(c => c.NewzbinPassword)
|
|
|
|
.Returns("smartar39865");
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-06-03 04:15:19 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
var result = Mocker.Resolve<Newzbin>().FetchEpisode(title, season, episode);
|
2011-06-03 04:15:19 +03:00
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
Mark500Inconclusive();
|
2011-06-03 04:15:19 +03:00
|
|
|
result.Should().NotBeEmpty();
|
2011-05-27 09:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-02-27 08:33:24 +03: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 08:32:55 +03:00
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
2011-06-04 08:32:55 +03:00
|
|
|
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-06-04 08:32:55 +03:00
|
|
|
|
2012-02-27 08:33:24 +03:00
|
|
|
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode(title, season, episode);
|
2011-06-04 08:32:55 +03:00
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
Mark500Inconclusive();
|
2011-10-17 06:51:15 +03:00
|
|
|
|
2011-06-04 08:32:55 +03:00
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
}
|
2011-05-27 09:03:57 +03:00
|
|
|
|
2011-06-04 08:32:55 +03:00
|
|
|
|
2012-02-27 08:33:24 +03:00
|
|
|
|
2011-06-04 08:32:55 +03:00
|
|
|
[Test]
|
|
|
|
public void nzbmatrix_multi_word_search_returns_valid_results()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
2011-06-04 08:32:55 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-06-04 08:32:55 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Blue Bloods", 1, 19);
|
2011-06-04 08:32:55 +03:00
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
Mark500Inconclusive();
|
2011-10-17 06:51:15 +03:00
|
|
|
|
2011-06-04 08:32:55 +03:00
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
}
|
2011-07-04 01:32:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
[TestCase("hawaii five-0 (2010)", "hawaii+five+0+2010")]
|
|
|
|
[TestCase("this& that", "this+that")]
|
|
|
|
[TestCase("this& that", "this+that")]
|
2012-02-11 11:09:28 +03:00
|
|
|
[TestCase("grey's anatomy", "grey+s+anatomy")]
|
2011-07-04 01:32:36 +03:00
|
|
|
public void get_query_title(string raw, string clean)
|
|
|
|
{
|
2012-02-11 11:09:28 +03:00
|
|
|
var mock = new Mock<IndexerBase>();
|
2012-02-27 08:33:24 +03:00
|
|
|
mock.CallBase = true;
|
2012-02-11 11:09:28 +03:00
|
|
|
var result = mock.Object.GetQueryTitle(raw);
|
|
|
|
result.Should().Be(clean);
|
|
|
|
}
|
2011-07-04 01:32:36 +03:00
|
|
|
|
2012-02-11 11:09:28 +03: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 01:32:36 +03:00
|
|
|
result.Should().Be(clean);
|
|
|
|
}
|
|
|
|
|
2011-09-14 05:25:33 +03:00
|
|
|
[Test]
|
|
|
|
public void size_newzbin()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 05:25:33 +03:00
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 07:15:53 +03:00
|
|
|
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
|
2011-09-14 05:25:33 +03:00
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
parseResults[0].Size.Should().Be(1295620506);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void size_nzbmatrix()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
2011-09-14 05:25:33 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 05:25:33 +03:00
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbmatrix.xml"));
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 07:15:53 +03:00
|
|
|
var parseResults = Mocker.Resolve<NzbMatrix>().FetchRss();
|
2011-09-14 05:25:33 +03:00
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
parseResults[0].Size.Should().Be(1331439862);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void size_nzbsorg()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
2011-07-04 01:32:36 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 05:25:33 +03:00
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsorg.xml"));
|
2011-07-04 01:32:36 +03:00
|
|
|
|
2011-09-14 05:25:33 +03:00
|
|
|
//Act
|
2011-12-15 07:15:53 +03:00
|
|
|
var parseResults = Mocker.Resolve<NzbsOrg>().FetchRss();
|
2011-07-04 01:32:36 +03:00
|
|
|
|
2011-09-14 05:25:33 +03:00
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
parseResults[0].Size.Should().Be(1793148846);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void size_nzbsrus()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
2011-09-14 05:25:33 +03:00
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
2011-09-14 05:25:33 +03:00
|
|
|
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
|
|
|
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsrus.xml"));
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 07:15:53 +03:00
|
|
|
var parseResults = Mocker.Resolve<NzbsRUs>().FetchRss();
|
2011-09-14 05:25:33 +03:00
|
|
|
|
|
|
|
parseResults.Should().HaveCount(1);
|
|
|
|
parseResults[0].Size.Should().Be(1793148846);
|
|
|
|
}
|
2011-11-21 06:49:04 +03:00
|
|
|
|
2012-01-21 22:36:22 +03: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 06:01:16 +03:00
|
|
|
|
2012-01-21 22:36:22 +03:00
|
|
|
ExceptionVerification.ExpectedErrors(0);
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void none_503_server_error_should_still_log_error()
|
|
|
|
{
|
2012-02-01 04:37:36 +03:00
|
|
|
WithConfiguredIndexers();
|
|
|
|
|
2012-01-21 22:36:22 +03: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 04:37:36 +03:00
|
|
|
[Test]
|
|
|
|
public void indexer_that_isnt_configured_shouldnt_make_an_http_call()
|
|
|
|
{
|
|
|
|
Mocker.Resolve<NotConfiguredIndexer>().FetchRss();
|
2012-02-27 08:33:24 +03:00
|
|
|
|
2012-02-01 04:37:36 +03:00
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
.Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
}
|
|
|
|
|
2012-01-23 07:29:09 +03:00
|
|
|
private static void Mark500Inconclusive()
|
2011-11-21 06:49:04 +03:00
|
|
|
{
|
|
|
|
ExceptionVerification.MarkInconclusive(typeof(WebException));
|
2012-01-23 07:24:39 +03:00
|
|
|
ExceptionVerification.MarkInconclusive("System.Net.WebException");
|
2012-01-23 07:34:30 +03:00
|
|
|
ExceptionVerification.MarkInconclusive("(503) Server Unavailable.");
|
2012-02-25 22:57:56 +03:00
|
|
|
ExceptionVerification.MarkInconclusive("(500) Internal Server Error.");
|
2011-11-21 06:49:04 +03:00
|
|
|
}
|
2011-09-14 05:25:33 +03:00
|
|
|
}
|
2011-05-27 05:12:28 +03:00
|
|
|
}
|