|
|
@ -1,17 +1,14 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Runtime.Remoting.Messaging;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
|
|
|
using FluentValidation.Results;
|
|
|
|
using Moq;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
using NzbDrone.Core.Indexers.Newznab;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Indexers.Omgwtfnzbs;
|
|
|
|
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
|
|
|
using NzbDrone.Core.ThingiProvider;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
|
@ -21,52 +18,44 @@ namespace NzbDrone.Core.Test.IndexerTests
|
|
|
|
public class SeasonSearchFixture : TestBase<FetchFeedService>
|
|
|
|
public class SeasonSearchFixture : TestBase<FetchFeedService>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private Series _series;
|
|
|
|
private Series _series;
|
|
|
|
private IIndexer _newznab;
|
|
|
|
|
|
|
|
private IIndexer _omgwtfnzbs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_series = Builder<Series>.CreateNew().Build();
|
|
|
|
_series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
|
|
_newznab = new Newznab();
|
|
|
|
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>())).Returns("<xml></xml>");
|
|
|
|
|
|
|
|
|
|
|
|
_newznab.Definition = new IndexerDefinition();
|
|
|
|
|
|
|
|
_newznab.Definition.Name = "nzbs.org";
|
|
|
|
|
|
|
|
_newznab.Definition.Settings = new NewznabSettings
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ApiKey = "",
|
|
|
|
|
|
|
|
Url = "http://nzbs.org"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_omgwtfnzbs = new Omgwtfnzbs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_omgwtfnzbs.Definition = new IndexerDefinition();
|
|
|
|
|
|
|
|
_omgwtfnzbs.Definition.Name = "omgwtfnzbs";
|
|
|
|
|
|
|
|
_omgwtfnzbs.Definition.Settings = new OmgwtfnzbsSettings
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ApiKey = "",
|
|
|
|
|
|
|
|
Username = "NzbDrone"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void WithResults(int count)
|
|
|
|
private IndexerBase<TestIndexerSettings> WithIndexer(bool paging, int resultCount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var results = Builder<ReleaseInfo>.CreateListOfSize(count)
|
|
|
|
var results = Builder<ReleaseInfo>.CreateListOfSize(resultCount)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IIndexerParsingService>()
|
|
|
|
var indexer = Mocker.GetMock<IndexerBase<TestIndexerSettings>>();
|
|
|
|
.Setup(s => s.Parse(It.IsAny<IIndexer>(), It.IsAny<String>(), It.IsAny<String>()))
|
|
|
|
|
|
|
|
|
|
|
|
indexer.Setup(s => s.Parser.Process(It.IsAny<String>(), It.IsAny<String>()))
|
|
|
|
.Returns(results);
|
|
|
|
.Returns(results);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>())).Returns("<xml></xml>");
|
|
|
|
indexer.Setup(s => s.GetSeasonSearchUrls(It.IsAny<String>(), It.IsAny<Int32>(), It.IsAny<Int32>(), It.IsAny<Int32>()))
|
|
|
|
|
|
|
|
.Returns(new List<string> { "http://www.nzbdrone.com" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
indexer.SetupGet(s => s.SupportsPaging).Returns(paging);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var definition = new IndexerDefinition();
|
|
|
|
|
|
|
|
definition.Name = "Test";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
indexer.SetupGet(s => s.Definition)
|
|
|
|
|
|
|
|
.Returns(definition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return indexer.Object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_not_use_offset_if_result_count_is_less_than_90()
|
|
|
|
public void should_not_use_offset_if_result_count_is_less_than_90()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithResults(25);
|
|
|
|
var indexer = WithIndexer(true, 25);
|
|
|
|
Subject.Fetch(_newznab, new SeasonSearchCriteria { Series = _series, SceneTitle = _series.Title });
|
|
|
|
Subject.Fetch(indexer, new SeasonSearchCriteria { Series = _series, SceneTitle = _series.Title });
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IHttpProvider>().Verify(v => v.DownloadString(It.IsAny<String>()), Times.Once());
|
|
|
|
Mocker.GetMock<IHttpProvider>().Verify(v => v.DownloadString(It.IsAny<String>()), Times.Once());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -74,8 +63,8 @@ namespace NzbDrone.Core.Test.IndexerTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_not_use_offset_for_sites_that_do_not_support_it()
|
|
|
|
public void should_not_use_offset_for_sites_that_do_not_support_it()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithResults(25);
|
|
|
|
var indexer = WithIndexer(false, 125);
|
|
|
|
Subject.Fetch(_omgwtfnzbs, new SeasonSearchCriteria { Series = _series, SceneTitle = _series.Title });
|
|
|
|
Subject.Fetch(indexer, new SeasonSearchCriteria { Series = _series, SceneTitle = _series.Title });
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IHttpProvider>().Verify(v => v.DownloadString(It.IsAny<String>()), Times.Once());
|
|
|
|
Mocker.GetMock<IHttpProvider>().Verify(v => v.DownloadString(It.IsAny<String>()), Times.Once());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -83,10 +72,18 @@ namespace NzbDrone.Core.Test.IndexerTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_not_use_offset_if_its_already_tried_10_times()
|
|
|
|
public void should_not_use_offset_if_its_already_tried_10_times()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithResults(100);
|
|
|
|
var indexer = WithIndexer(true, 100);
|
|
|
|
Subject.Fetch(_newznab, new SeasonSearchCriteria { Series = _series, SceneTitle = _series.Title });
|
|
|
|
Subject.Fetch(indexer, new SeasonSearchCriteria { Series = _series, SceneTitle = _series.Title });
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IHttpProvider>().Verify(v => v.DownloadString(It.IsAny<String>()), Times.Exactly(11));
|
|
|
|
Mocker.GetMock<IHttpProvider>().Verify(v => v.DownloadString(It.IsAny<String>()), Times.Exactly(11));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TestIndexerSettings : IProviderConfig
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public ValidationResult Validate()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|