1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-19 21:46:50 -04:00
Files
Radarr/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs
T
Leonardo Galli 7cfa0531dc Fixed all tests and even added some new ones :) (#835)
* First fixing of tests.

* Updated more tests.

* Fix some tests

* Fix all prioritization tests.

And add new for preferred words.

* Updated CompletedDownloadservice tests

* Fixed a lot of tests

* Fixed all indexer requests. We should add more for the indexers we added.

To lazy for that though ¯\_(ツ)_/¯

* Fixed organizer tests.

Should probably be also updated to incorporate our newly added tags.

* Fix notification tests.

* Fixed update test for osx

* Fixed a few more tests.

* Fixed some more tests.

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update activity.less

* Update appveyor.yml

* Update appveyor.yml

* Update CommonVersionInfo.cs

* Update build-appveyor.cake

Let's hope this works.

* Update CommonVersionInfo.cs

Just to kickstart appveyor

* Fixed a few tests

* Just ignore those tests.

* Fixed more tests.

* First steps in fixing Core.Test.Download.DownloadApprovedFixture

* Fix most DownloadApprovedFixture tests

* Fixed something.

* Fixed a few more tests.

* Fixed pending release tests.

* All Core tests are now fixed.

* Fixed the last tests :)

* Fixed Download Station Tests.

* Fixed Vuze and Transmission default settings which caused the tests to fail.

* Fix most tests.

* Fix RootFolder tests.

* Fixed last tests
2017-03-06 22:23:25 +01:00

122 lines
3.6 KiB
C#

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 MovieSearchCriteria _movieSearchCriteria;
private NewznabCapabilities _capabilities;
[SetUp]
public void SetUp()
{
Subject.Settings = new NewznabSettings()
{
Url = "http://127.0.0.1:1234/",
Categories = new [] { 1, 2 },
AnimeCategories = new [] { 3, 4 },
ApiKey = "abcd",
};
_movieSearchCriteria = new MovieSearchCriteria
{
Movie = new Tv.Movie { ImdbId = "tt0076759", Title = "Star Wars", Year = 1977 }
};
_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,3,4&");
}
[Test]
public void should_not_have_duplicate_categories()
{
Subject.Settings.Categories = new[] { 1, 2, 3 };
var results = Subject.GetRecentRequests();
results.GetAllTiers().Should().HaveCount(1);
var page = results.GetAllTiers().First().First();
page.Url.FullUri.Should().Contain("&cat=1,2,3,4&");
}
[Test]
public void should_return_subsequent_pages()
{
var results = Subject.GetSearchRequests(_movieSearchCriteria);
results.GetAllTiers().Should().HaveCount(1);
var pages = results.GetAllTiers().First().Take(3).ToList();
pages[0].Url.FullUri.Should().Contain("&offset=0&");
pages[1].Url.FullUri.Should().Contain("&offset=100&");
pages[2].Url.FullUri.Should().Contain("&offset=200&");
}
[Test]
public void should_not_get_unlimited_pages()
{
var results = Subject.GetSearchRequests(_movieSearchCriteria);
results.GetAllTiers().Should().HaveCount(1);
var pages = results.GetAllTiers().First().Take(500).ToList();
pages.Count.Should().BeLessThan(500);
}
[Test]
public void should_not_search_by_imdbid_if_not_supported()
{
_capabilities.SupportedMovieSearchParameters = new[] { "q" };
var results = Subject.GetSearchRequests(_movieSearchCriteria);
results.GetAllTiers().Should().HaveCount(1);
var page = results.GetAllTiers().First().First();
page.Url.Query.Should().NotContain("imdbid=0076759");
page.Url.Query.Should().Contain("q=star");
}
[Test]
public void should_search_by_imdbid_if_supported()
{
_capabilities.SupportedMovieSearchParameters = new[] { "q", "imdbid" };
var results = Subject.GetSearchRequests(_movieSearchCriteria);
results.GetTier(0).Should().HaveCount(1);
var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("imdbid=0076759");
}
}
}