You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
77 lines
2.4 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FluentAssertions;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Core.Indexers.Newznab;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
|
{
|
|
public class NewznabRequestGeneratorFixture : CoreTest<NewznabRequestGenerator>
|
|
{
|
|
private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria;
|
|
private AlbumSearchCriteria _singleAlbumSearchCriteria;
|
|
private NewznabCapabilities _capabilities;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
Subject.Settings = new NewznabSettings()
|
|
{
|
|
Url = "http://127.0.0.1:1234/",
|
|
Categories = new [] { 1, 2 },
|
|
ApiKey = "abcd",
|
|
};
|
|
|
|
_singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria
|
|
{
|
|
Series = new Tv.Series { TvRageId = 10, TvdbId = 20, TvMazeId = 30 },
|
|
SceneTitles = new List<string> { "Monkey Island" },
|
|
SeasonNumber = 1,
|
|
EpisodeNumber = 2
|
|
};
|
|
|
|
_singleAlbumSearchCriteria = new AlbumSearchCriteria
|
|
{
|
|
Artist = new Music.Artist { Name = "Alien Ant Farm" },
|
|
Album = new Music.Album { Title = "TruANT" }
|
|
|
|
};
|
|
|
|
_capabilities = new NewznabCapabilities();
|
|
|
|
Mocker.GetMock<INewznabCapabilitiesProvider>()
|
|
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
|
|
.Returns(_capabilities);
|
|
}
|
|
|
|
[Test]
|
|
public void should_use_all_categories_for_feed()
|
|
{
|
|
var results = Subject.GetRecentRequests();
|
|
|
|
results.GetAllTiers().Should().HaveCount(1);
|
|
|
|
var page = results.GetAllTiers().First().First();
|
|
|
|
page.Url.Query.Should().Contain("&cat=1,2&");
|
|
}
|
|
|
|
[Test]
|
|
public void should_search_by_artist_and_album_if_supported()
|
|
{
|
|
_capabilities.SupportedAudioSearchParameters = new[] { "q", "artist", "album"};
|
|
|
|
var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria);
|
|
results.GetTier(0).Should().HaveCount(1);
|
|
|
|
var page = results.GetAllTiers().First().First();
|
|
|
|
page.Url.Query.Should().Contain("artist=Alien Ant Farm");
|
|
page.Url.Query.Should().Contain("album=TruANT");
|
|
}
|
|
}
|
|
}
|