2011-10-23 20:35:16 +00:00
|
|
|
|
using AutoMoq;
|
2011-10-23 18:31:17 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
2011-10-23 05:26:43 +00:00
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
2011-10-23 18:31:17 +00:00
|
|
|
|
using NzbDrone.Common.Model;
|
2011-10-23 05:26:43 +00:00
|
|
|
|
using NzbDrone.Update.Providers;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Update.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-10-23 18:31:17 +00:00
|
|
|
|
class UpdateProviderStartTest
|
2011-10-23 05:26:43 +00:00
|
|
|
|
{
|
|
|
|
|
AutoMoqer mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
mocker = new AutoMoqer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-10-23 18:31:17 +00:00
|
|
|
|
public void should_stop_nzbdrone_service_if_installed()
|
2011-10-23 05:26:43 +00:00
|
|
|
|
{
|
2011-10-23 18:31:17 +00:00
|
|
|
|
mocker.GetMock<ServiceProvider>()
|
|
|
|
|
.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName))
|
|
|
|
|
.Returns(true);
|
2011-10-23 05:26:43 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-10-23 18:31:17 +00:00
|
|
|
|
mocker.Resolve<UpdateProvider>().Start(null);
|
2011-10-23 05:26:43 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-10-23 18:31:17 +00:00
|
|
|
|
mocker.GetMock<ServiceProvider>().Verify(c => c.Stop(ServiceProvider.NzbDroneServiceName), Times.Once());
|
2011-10-23 05:26:43 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-10-23 18:31:17 +00:00
|
|
|
|
public void should_kill_nzbdrone_process_if_running()
|
2011-10-23 05:26:43 +00:00
|
|
|
|
{
|
2011-10-23 18:31:17 +00:00
|
|
|
|
var proccesses = Builder<ProcessInfo>.CreateListOfSize(2).Build();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<ProcessProvider>()
|
|
|
|
|
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))
|
|
|
|
|
.Returns(proccesses);
|
2011-10-23 05:26:43 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-10-23 18:31:17 +00:00
|
|
|
|
mocker.Resolve<UpdateProvider>().Start(null);
|
2011-10-23 05:26:43 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-10-23 18:31:17 +00:00
|
|
|
|
mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[0].Id), Times.Once());
|
|
|
|
|
mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[1].Id), Times.Once());
|
2011-10-23 05:26:43 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|