2017-10-27 03:21:06 +00:00
|
|
|
using System;
|
2014-02-26 05:40:47 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
using NzbDrone.Core.HealthCheck.Checks;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class DownloadClientCheckFixture : CoreTest<DownloadClientCheck>
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void should_return_warning_when_download_client_has_not_been_configured()
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IProvideDownloadClient>()
|
2014-04-19 15:09:22 +00:00
|
|
|
.Setup(s => s.GetDownloadClients())
|
|
|
|
.Returns(new IDownloadClient[0]);
|
2014-02-26 05:40:47 +00:00
|
|
|
|
|
|
|
Subject.Check().ShouldBeWarning();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_return_error_when_download_client_throws()
|
|
|
|
{
|
|
|
|
var downloadClient = Mocker.GetMock<IDownloadClient>();
|
2020-01-03 12:49:24 +00:00
|
|
|
downloadClient.Setup(s => s.Definition).Returns(new DownloadClientDefinition { Name = "Test" });
|
2014-02-26 05:40:47 +00:00
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
downloadClient.Setup(s => s.GetItems())
|
2014-02-26 05:40:47 +00:00
|
|
|
.Throws<Exception>();
|
|
|
|
|
|
|
|
Mocker.GetMock<IProvideDownloadClient>()
|
2014-04-19 15:09:22 +00:00
|
|
|
.Setup(s => s.GetDownloadClients())
|
|
|
|
.Returns(new IDownloadClient[] { downloadClient.Object });
|
2014-02-26 05:40:47 +00:00
|
|
|
|
|
|
|
Subject.Check().ShouldBeError();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2014-04-10 00:15:13 +00:00
|
|
|
public void should_return_ok_when_download_client_returns()
|
2014-02-26 05:40:47 +00:00
|
|
|
{
|
|
|
|
var downloadClient = Mocker.GetMock<IDownloadClient>();
|
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
downloadClient.Setup(s => s.GetItems())
|
|
|
|
.Returns(new List<DownloadClientItem>());
|
2014-02-26 05:40:47 +00:00
|
|
|
|
|
|
|
Mocker.GetMock<IProvideDownloadClient>()
|
2014-04-19 15:09:22 +00:00
|
|
|
.Setup(s => s.GetDownloadClients())
|
|
|
|
.Returns(new IDownloadClient[] { downloadClient.Object });
|
2014-02-26 05:40:47 +00:00
|
|
|
|
2014-04-10 00:15:13 +00:00
|
|
|
Subject.Check().ShouldBeOk();
|
2014-02-26 05:40:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|