2012-03-02 19:58:31 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2011-10-07 06:36:04 +00:00
|
|
|
|
using System.Linq;
|
2011-11-14 00:22:18 +00:00
|
|
|
|
|
2011-10-07 06:36:04 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2011-10-23 05:26:43 +00:00
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
using NzbDrone.Common.Model;
|
2011-11-13 18:16:31 +00:00
|
|
|
|
using NzbDrone.Test.Common;
|
2011-10-07 06:36:04 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.App.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-11-13 18:16:31 +00:00
|
|
|
|
public class MonitoringProviderTest : TestBase
|
2011-10-07 06:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
|
|
|
|
|
{
|
2012-03-02 19:58:31 +00:00
|
|
|
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess())
|
2011-10-07 06:36:04 +00:00
|
|
|
|
.Returns(Builder<ProcessInfo>.CreateNew().With(c => c.Priority == ProcessPriorityClass.Normal).Build());
|
|
|
|
|
|
2012-03-02 19:58:31 +00:00
|
|
|
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
|
2011-10-07 06:36:04 +00:00
|
|
|
|
|
2013-03-01 00:50:50 +00:00
|
|
|
|
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
|
2012-03-02 19:58:31 +00:00
|
|
|
|
}
|
2011-10-07 06:36:04 +00:00
|
|
|
|
|
2012-03-02 19:58:31 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void Ensure_should_log_warn_exception_rather_than_throw()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
|
2013-03-01 00:50:50 +00:00
|
|
|
|
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
|
2011-10-07 06:36:04 +00:00
|
|
|
|
|
2012-03-02 19:58:31 +00:00
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
2011-10-07 06:36:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|