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.
Readarr/src/NzbDrone.Core.Test/IndexerTests/IntegrationTests/IndexerIntegrationTests.cs

63 lines
2.0 KiB

using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
{
[IntegrationTest]
public class IndexerIntegrationTests : CoreTest
{
private BookSearchCriteria _bookSearchCriteria;
[SetUp]
public void SetUp()
{
UseRealHttp();
_bookSearchCriteria = new BookSearchCriteria()
{
};
}
private void ValidateTorrentResult(IList<ReleaseInfo> reports, bool hasSize = false, bool hasInfoUrl = false, bool hasMagnet = false)
{
reports.Should().OnlyContain(c => c.GetType() == typeof(TorrentInfo));
ValidateResult(reports, hasSize, hasInfoUrl);
reports.Should().OnlyContain(c => c.DownloadProtocol == DownloadProtocol.Torrent);
if (hasMagnet)
{
reports.Cast<TorrentInfo>().Should().OnlyContain(c => c.MagnetUrl.StartsWith("magnet:"));
}
}
private void ValidateResult(IList<ReleaseInfo> reports, bool hasSize = false, bool hasInfoUrl = false)
{
reports.Should().NotBeEmpty();
reports.Should().OnlyContain(c => c.Title.IsNotNullOrWhiteSpace());
reports.Should().OnlyContain(c => c.PublishDate.Year > 2000);
reports.Should().OnlyContain(c => c.DownloadUrl.IsNotNullOrWhiteSpace());
reports.Should().OnlyContain(c => c.DownloadUrl.StartsWith("http"));
if (hasInfoUrl)
{
reports.Should().OnlyContain(c => c.InfoUrl.IsNotNullOrWhiteSpace());
}
if (hasSize)
{
reports.Should().OnlyContain(c => c.Size > 0);
}
}
}
}