mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
1787852360
Fix: Issue where an uncritical subsystem could crash the app.
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
|
|
using FizzWare.NBuilder;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common;
|
|
using NzbDrone.Common.Model;
|
|
using NzbDrone.Providers;
|
|
using NzbDrone.Test.Common;
|
|
|
|
namespace NzbDrone.App.Test
|
|
{
|
|
[TestFixture]
|
|
public class MonitoringProviderTest : TestBase
|
|
{
|
|
|
|
[Test]
|
|
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
|
|
{
|
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess())
|
|
.Returns(Builder<ProcessInfo>.CreateNew().With(c => c.Priority == ProcessPriorityClass.Normal).Build());
|
|
|
|
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
|
|
|
|
Mocker.Resolve<MonitoringProvider>().EnsurePriority(null);
|
|
}
|
|
|
|
[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);
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
}
|
|
|
|
|
|
}
|
|
}
|