New: NzbInfoUrl added to history (link to NZB info at indexer) - Not supported for Womble's.

This commit is contained in:
Mark McDowall 2012-05-02 15:42:21 -07:00
commit 5aff4ab240
12 changed files with 639 additions and 462 deletions

View file

@ -55,7 +55,6 @@ namespace NzbDrone.Core.Test
Uri.PathAndQuery.Should().NotContain("//");
}
parseResults.Should().NotBeEmpty();
parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name);
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
@ -75,6 +74,9 @@ namespace NzbDrone.Core.Test
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
}
[Test]
@ -563,38 +565,191 @@ namespace NzbDrone.Core.Test
Thread.CurrentThread.CurrentCulture = currentCulture;
}
[TestCase("nzbsorg.xml", "info")]
[TestCase("nzbsrus.xml", "info")]
[TestCase("newzbin.xml", "info")]
[TestCase("nzbmatrix.xml", "info")]
[TestCase("newznab.xml", "info")]
[TestCase("wombles.xml", "info")]
[TestCase("filesharingtalk.xml", "info")]
[TestCase("nzbindex.xml", "info")]
[TestCase("nzbclub.xml", "info")]
public void NzbInfoUrl_should_contain_information_string(string fileName, string expectedContent)
[Test]
public void NzbsOrg_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "nzbsorg.xml";
const string expectedString = "action=view";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
var mockIndexer = Mocker.Resolve<MockIndexer>();
var parseResults = mockIndexer.FetchRss();
var parseResults = Mocker.Resolve<NzbsOrg>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedContent);
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void NzbsRus_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "nzbsrus.xml";
const string expectedString = "nzbdetails";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<NzbsRUs>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void Newzbin_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "newzbin.xml";
const string expectedString = "browse";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void NzbMatrix_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "nzbmatrix.xml";
const string expectedString = "nzb-details";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<NzbMatrix>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void Newznab_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "newznab.xml";
const string expectedString = "/details/";
var newznabDefs = Builder<NewznabDefinition>.CreateListOfSize(1)
.All()
.With(n => n.ApiKey = String.Empty)
.Build();
Mocker.GetMock<NewznabProvider>().Setup(s => s.Enabled()).Returns(newznabDefs.ToList());
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<Newznab>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void Wombles_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "wombles.xml";
const string expectedString = "nzbdetails";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<Wombles>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().BeNull();
}
}
[Test]
public void FileSharingTalk_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "filesharingtalk.xml";
const string expectedString = "/nzbs/tv";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<FileSharingTalk>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void NzbIndex_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "nzbindex.xml";
const string expectedString = "release";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<NzbIndex>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void NzbClub_NzbInfoUrl_should_contain_information_string()
{
WithConfiguredIndexers();
const string fileName = "nzbclub.xml";
const string expectedString = "nzb_view";
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var parseResults = Mocker.Resolve<NzbClub>().FetchRss();
foreach (var episodeParseResult in parseResults)
{
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
parseResults.Should().NotBeEmpty();
parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name);
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
parseResults.Should().OnlyContain(s => s.Age >= 0);
}
}
}