1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.App.Test/MonitoringProviderTest.cs

42 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics;
2011-10-07 09:36:04 +03:00
using System.Linq;
2011-10-07 09:36:04 +03:00
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Model;
2011-10-07 09:36:04 +03:00
using NzbDrone.Providers;
2011-11-13 21:16:31 +03:00
using NzbDrone.Test.Common;
2011-10-07 09:36:04 +03:00
namespace NzbDrone.App.Test
{
[TestFixture]
2011-11-13 21:16:31 +03:00
public class MonitoringProviderTest : TestBase
2011-10-07 09:36:04 +03:00
{
[Test]
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
{
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess())
2011-10-07 09:36:04 +03:00
.Returns(Builder<ProcessInfo>.CreateNew().With(c => c.Priority == ProcessPriorityClass.Normal).Build());
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
2011-10-07 09:36:04 +03:00
Mocker.Resolve<MonitoringProvider>().EnsurePriority(null);
}
2011-10-07 09:36:04 +03:00
[Test]
public void Ensure_should_log_warn_exception_rather_than_throw()
{
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
Mocker.Resolve<MonitoringProvider>().EnsurePriority(null);
2011-10-07 09:36:04 +03:00
ExceptionVerification.ExpectedWarns(1);
2011-10-07 09:36:04 +03:00
}
}
}