1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00
Radarr/NzbDrone.Update.Test/StartNzbDroneService.cs

40 lines
1.3 KiB
C#
Raw Normal View History

using System;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common;
using NzbDrone.Update.UpdateEngine;
2013-07-24 07:35:32 +02:00
using IServiceProvider = NzbDrone.Common.IServiceProvider;
namespace NzbDrone.Update.Test
{
[TestFixture]
public class StartNzbDroneServiceFixture : TestBase<StartNzbDrone>
{
[Test]
public void should_start_service_if_app_type_was_serivce()
{
const string targetFolder = "c:\\NzbDrone\\";
Subject.Start(AppType.Service, targetFolder);
2013-07-24 07:35:32 +02:00
Mocker.GetMock<IServiceProvider>().Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
[Test]
public void should_start_console_if_app_type_was_service_but_start_failed_because_of_permissions()
{
const string targetFolder = "c:\\NzbDrone\\";
2013-07-24 07:35:32 +02:00
Mocker.GetMock<IServiceProvider>().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException());
Subject.Start(AppType.Service, targetFolder);
Mocker.GetMock<IProcessProvider>().Verify(c => c.SpawnNewProcess("c:\\NzbDrone\\NzbDrone.Console.exe", StartupArguments.NO_BROWSER), Times.Once());
ExceptionVerification.ExpectedWarns(1);
}
}
}