2013-04-01 06:22:16 +00:00
|
|
|
using System;
|
2013-01-24 06:36:37 +00:00
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common;
|
2013-02-24 06:48:52 +00:00
|
|
|
using NzbDrone.Core.Configuration;
|
2013-03-05 05:33:34 +00:00
|
|
|
using NzbDrone.Core.Download.Clients.Nzbget;
|
2013-03-28 19:05:43 +00:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
2013-01-24 06:36:37 +00:00
|
|
|
|
2013-04-01 06:22:16 +00:00
|
|
|
namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
2013-01-24 06:36:37 +00:00
|
|
|
{
|
2013-03-28 19:05:43 +00:00
|
|
|
public class QueueFixture : CoreTest
|
2013-01-24 06:36:37 +00:00
|
|
|
{
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2013-02-24 19:39:31 +00:00
|
|
|
var fakeConfig = Mocker.GetMock<IConfigService>();
|
2013-01-24 06:36:37 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void WithFullQueue()
|
|
|
|
{
|
2013-04-10 23:41:45 +00:00
|
|
|
Mocker.GetMock<IHttpProvider>()
|
2013-01-24 07:38:16 +00:00
|
|
|
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
2013-03-28 19:05:43 +00:00
|
|
|
.Returns(ReadAllText("Files", "Nzbget", "Queue.txt"));
|
2013-01-24 06:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void WithEmptyQueue()
|
|
|
|
{
|
2013-04-10 23:41:45 +00:00
|
|
|
Mocker.GetMock<IHttpProvider>()
|
2013-01-24 07:38:16 +00:00
|
|
|
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
2013-03-28 19:05:43 +00:00
|
|
|
.Returns(ReadAllText("Files", "Nzbget", "Queue_empty.txt"));
|
2013-01-24 06:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void WithFailResponse()
|
|
|
|
{
|
2013-04-10 23:41:45 +00:00
|
|
|
Mocker.GetMock<IHttpProvider>()
|
2013-01-24 07:38:16 +00:00
|
|
|
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
2013-03-28 19:05:43 +00:00
|
|
|
.Returns(ReadAllText("Files", "Nzbget", "JsonError.txt"));
|
2013-01-24 06:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_return_no_items_when_queue_is_empty()
|
|
|
|
{
|
|
|
|
WithEmptyQueue();
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
Mocker.Resolve<NzbgetClient>()
|
2013-01-24 06:36:37 +00:00
|
|
|
.GetQueue()
|
|
|
|
.Should()
|
|
|
|
.BeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_return_item_when_queue_has_item()
|
|
|
|
{
|
|
|
|
WithFullQueue();
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
Mocker.Resolve<NzbgetClient>()
|
2013-01-24 06:36:37 +00:00
|
|
|
.GetQueue()
|
|
|
|
.Should()
|
|
|
|
.HaveCount(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|