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