sonarr-repo-only/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs

101 lines
2.9 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using FluentAssertions;
2013-06-04 03:33:03 +00:00
using NzbDrone.Core.Indexers;
2013-09-13 23:17:58 +00:00
using NzbDrone.Core.Indexers.Eztv;
2013-06-04 03:33:03 +00:00
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Indexers.Wombles;
using NzbDrone.Core.Parser.Model;
2013-06-04 03:33:03 +00:00
using NzbDrone.Core.Test.Framework;
using NUnit.Framework;
using NzbDrone.Test.Common.Categories;
2013-09-13 23:17:58 +00:00
using System.Linq;
2013-06-04 03:33:03 +00:00
namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
{
[IntegrationTest]
2013-06-04 03:33:03 +00:00
public class IndexerIntegrationTests : CoreTest<FetchFeedService>
{
[SetUp]
public void SetUp()
2013-06-04 03:33:03 +00:00
{
UseRealHttp();
}
2013-06-04 03:33:03 +00:00
[Test]
public void wombles_rss()
{
var indexer = new Wombles();
var result = Subject.FetchRss(indexer);
ValidateResult(result, skipSize: true, skipInfo: true);
}
2013-09-13 23:17:58 +00:00
[Test]
public void extv_rss()
{
var indexer = new Eztv();
var result = Subject.FetchRss(indexer);
ValidateTorrentResult(result, skipSize: false, skipInfo: true);
}
2013-06-04 03:33:03 +00:00
[Test]
public void nzbsorg_rss()
{
var indexer = new Newznab();
indexer.Settings = new NewznabSettings
{
2013-08-30 02:27:23 +00:00
ApiKey = "64d61d3cfd4b75e51d01cbc7c6a78275",
2013-06-04 03:33:03 +00:00
Url = "http://nzbs.org"
};
indexer.InstanceDefinition = new IndexerDefinition();
2013-08-30 02:27:23 +00:00
indexer.InstanceDefinition.Name = "nzbs.org";
2013-06-04 03:33:03 +00:00
var result = Subject.FetchRss(indexer);
ValidateResult(result);
2013-06-04 03:33:03 +00:00
}
2013-09-13 23:17:58 +00:00
private void ValidateResult(IList<ReleaseInfo> reports, bool skipSize = false, bool skipInfo = false)
{
reports.Should().NotBeEmpty();
2013-09-13 23:17:58 +00:00
reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Title));
reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.DownloadUrl));
reports.Should().OnlyContain(c => c.PublishDate.Year > 2000);
reports.Should().OnlyContain(c => c.DownloadUrl.StartsWith("http"));
if (!skipInfo)
{
2013-09-13 23:17:58 +00:00
reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.InfoUrl));
}
if (!skipSize)
{
reports.Should().OnlyContain(c => c.Size > 0);
}
}
2013-09-13 23:17:58 +00:00
private void ValidateTorrentResult(IList<ReleaseInfo> reports, bool skipSize = false, bool skipInfo = false)
{
reports.Should().OnlyContain(c => c.GetType() == typeof(TorrentInfo));
ValidateResult(reports, skipSize, skipInfo);
reports.Should().OnlyContain(c => c.DownloadUrl.EndsWith(".torrent"));
reports.Cast<TorrentInfo>().Should().OnlyContain(c => c.MagnetUrl.StartsWith("magnet:"));
reports.Cast<TorrentInfo>().Should().NotContain(c => string.IsNullOrWhiteSpace(c.InfoHash));
}
2013-06-04 03:33:03 +00:00
}
2013-09-13 23:17:58 +00:00
}