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.
61 lines
2.3 KiB
61 lines
2.3 KiB
12 years ago
|
using System;
|
||
12 years ago
|
using FluentAssertions;
|
||
|
using Moq;
|
||
|
using NUnit.Framework;
|
||
|
using NzbDrone.Common;
|
||
12 years ago
|
using NzbDrone.Core.Configuration;
|
||
12 years ago
|
using NzbDrone.Core.Download.Clients.Nzbget;
|
||
12 years ago
|
using NzbDrone.Core.Test.Framework;
|
||
12 years ago
|
|
||
12 years ago
|
namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||
12 years ago
|
{
|
||
12 years ago
|
public class DownloadNzbFixture : CoreTest
|
||
12 years ago
|
{
|
||
|
[SetUp]
|
||
|
public void Setup()
|
||
|
{
|
||
12 years ago
|
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||
12 years ago
|
fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55");
|
||
|
fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789);
|
||
|
fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget");
|
||
|
fakeConfig.SetupGet(c => c.NzbgetPassword).Returns("pass");
|
||
|
fakeConfig.SetupGet(c => c.NzbgetTvCategory).Returns("TV");
|
||
|
fakeConfig.SetupGet(c => c.NzbgetBacklogTvPriority).Returns(PriorityType.Normal);
|
||
|
fakeConfig.SetupGet(c => c.NzbgetRecentTvPriority).Returns(PriorityType.High);
|
||
|
}
|
||
|
|
||
12 years ago
|
|
||
12 years ago
|
private void WithFailResponse()
|
||
|
{
|
||
|
Mocker.GetMock<HttpProvider>()
|
||
12 years ago
|
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
||
12 years ago
|
.Returns(ReadAllText("Files", "Nzbget", "JsonError.txt"));
|
||
12 years ago
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void should_add_item_to_queue()
|
||
|
{
|
||
|
const string url = "http://www.nzbdrone.com";
|
||
|
const string title = "30 Rock - S01E01 - Pilot [HDTV-720p]";
|
||
|
|
||
|
Mocker.GetMock<HttpProvider>()
|
||
12 years ago
|
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass",
|
||
12 years ago
|
It.Is<String>(c => c.Equals("{\"method\":\"appendurl\",\"params\":[\"30 Rock - S01E01 - Pilot [HDTV-720p]\",\"TV\",0,false,\"http://www.nzbdrone.com\"]}"))))
|
||
|
.Returns("{\"version\": \"1.1\",\"result\": true}");
|
||
|
|
||
|
Mocker.Resolve<NzbgetProvider>()
|
||
|
.DownloadNzb(url, title, false)
|
||
|
.Should()
|
||
|
.BeTrue();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void should_throw_when_error_is_returned()
|
||
|
{
|
||
|
WithFailResponse();
|
||
|
|
||
|
Assert.Throws<ApplicationException>(() => Mocker.Resolve<NzbgetProvider>().DownloadNzb("http://www.nzbdrone.com", "30 Rock - S01E01 - Pilot [HDTV-720p]", false));
|
||
|
}
|
||
|
}
|
||
|
}
|